Problem/Motivation
Any layout builder page that has custom blocks loses the AJAX ability to remove content and do a page refresh.
In order words one can't remove a block from a layout builder page and close the off-canvas tray with AJAX
Steps to reproduce
To reproduce install the module and try to remove any block.
The block will action will be taken but ajax won't run. Hence the block stays, the off-canvas stays open and the page does not reload.
Proposed resolution
I propose narrowing its scope so it won't interfere with other Drupal functions.
API changes
I tracked the issue to this hook.
/**
* Implements hook_form_alter().
*/
function entity_reference_actions_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$is_ajax = FALSE;
foreach (['drupal_ajax', 'drupal_modal', 'drupal_dialog'] as $wrapper) {
if (strpos(\Drupal::request()->get(MainContentViewSubscriber::WRAPPER_FORMAT), $wrapper) !== FALSE) {
$is_ajax = TRUE;
}
}
if (!$is_ajax || !($form_state->getFormObject() instanceof ConfirmFormBase)) {
return;
}
$form['actions']['submit']['#ajax']['callback'] = [
EntityReferenceActionsHandler::class,
'dialogAjaxSubmit',
];
$form['actions']['cancel']['#attributes']['class'][] = 'dialog-cancel';
}
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3191889.patch | 796 bytes | chr.fritsch |
Comments
Comment #2
chr.fritschHi @bernardm28,
could you please test this patch. Thx
Comment #3
chr.fritschPR: https://github.com/thunder/entity_reference_actions/pull/19/files
Comment #4
bernardm28 commentedHey, thanks for the patch. I haven't gone back to testing it yet. But the code looks good. Once I get it tested and I will let you know.
Comment #5
chr.fritschAny updates?
Comment #6
bernardm28 commentedThe patch works. Thanks for the contrib and sorry for the wait.
I try replicating the issue a few different ways but it seems like the issue its gone.
If there is a change you guys could do a demo video or blogpost about the module that be cool.
Comment #7
bernardm28 commentedComment #9
chr.fritsch