Modal Does not Close Automatically

Created on 10 March 2023, over 1 year ago

Problem/Motivation

After editing a block with Layout Builder using the iFrame Modal, clicking Save or Update does not close the modal or iframe but loads the changes inside of the modal iframe.

Steps to reproduce

Create or edit a block and save it

Proposed resolution

It looks like the change from 1.2.0 to 1.3.0 to `/src/Render/MainContent/IframeRenderer.php` from

```
$iframe_src->setOption('query', [
'destination' => '/layout_builder_iframe_modal/redirect',
]);
```

to

```
$iframe_src->setOption('query', [
'destination' => Url::fromRoute('layout_builder_iframe_modal.redirect')->toString(TRUE)->getGeneratedUrl(),
]);
```

may have caused this. When debugging this change, `Url::fromRoute('layout_builder_iframe_modal.redirect')->toString(TRUE)->getGeneratedUrl()` produces an absolute URL instead of a relative path, causing it to fail. I tried adding `setAbsolute(FALSE)` but it still created an absolute path.

πŸ› Bug report
Status

Active

Version

1.3

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States themarkahrens

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @themarkahrens
  • πŸ‡ΊπŸ‡ΈUnited States themarkahrens
  • πŸ‡ΊπŸ‡ΈUnited States themarkahrens
  • πŸ‡«πŸ‡·France vbouchet

    Hi Mark,
    Thanks for reporting. I have the 1.3.0 version as well and I can't reproduce the issue. Checking at the iframe src, I can see ?destination=/layout_builder_iframe_modal/redirect. When I submit, the modal is properly closed.

    Which version of Drupal are you using?

  • πŸ‡ΊπŸ‡ΈUnited States themarkahrens

    We are on Drupal 10.0.5 and seeing the issue.

  • πŸ‡ΊπŸ‡¦Ukraine Vadym.Tseiko

    Hi @vbouchet, I have the same issue here. My project is drupal/core-recommended: 9.5.7. I use drupal/layout_builder_iframe_modal: 1.3.0. At the moment we faced this issue, after adding multilingual functionality via drupal core built-in multilingual functionality. Using language detection via URL by domain. Just as Mark mentioned I tried to change following: 'destination' => Url::fromRoute('layout_builder_iframe_modal.redirect')->toString(TRUE)->getGeneratedUrl(), back to 'destination' => '/layout_builder_iframe_modal/redirect', and it works fine in that case. When I work with iframe without multilingual changes everything works fine.

  • πŸ‡ΊπŸ‡ΈUnited States themarkahrens

    I can confirm that our site is multilingual as well.

  • πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA
  • πŸ‡¨πŸ‡¦Canada dylan donkersgoed London, Ontario

    Dylan Donkersgoed β†’ made their first commit to this issue’s fork.

  • πŸ‡¨πŸ‡¦Canada dylan donkersgoed London, Ontario

    Same issue here, also on a multilingual site. I've opened a branch with the fix. It doesn't seem to want to let me open an MR right this second, but I'm attaching a patch with the fix.

    This fix basically just switches the generated URL to be relative. I'm not sure what the reason for the original change was so not sure this is an acceptable solution or if an absolute URL is actually needed. But it does solve the issue.

  • Status changed to Needs review about 1 year ago
  • πŸ‡¨πŸ‡¦Canada dylan donkersgoed London, Ontario
  • πŸ‡§πŸ‡·Brazil aluzzardi Pelotas, RS

    I had that same issue and the patch from #10 worked for me.
    It seems related to multilingual, when the language negotiation is configured to use domain instead of path_prefix
    I'm on Drupal 10.3.6 with module on 1.3.0

Production build 0.71.5 2024