Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image browser attached to field doesnt work if field is in a modal #6236

Closed
docwilmot opened this issue Sep 30, 2023 · 5 comments · Fixed by backdrop/backdrop#4526
Closed

Comments

@docwilmot
Copy link
Contributor

Description of the bug

If you implement a managed_file field and add the #browser_view key to the array, the button to browse existing files appears, and when clicked, launches the image browser in a modal. This works fine on forms like the node page, but what if your field is already in a modal? Well, the image browser modal pops out, and when you click the insert button closes the original modal too.

Steps To Reproduce

Simplest is to hack core: go to core/layout/includes/block.hero.inc and add '#browser_view' => 'image_library', to the $form['image'] array in the form() function. Then start add a Hero block to any layout, and you get this:

Screenshot 2023-09-30 140307

Actual behavior

But if you try to select existing file, after clicking insert it closes the Hero block config modal. The browser works fine if you add the #browser_view key to a field that's not in a modal. (Feel free to hack another core or contrib managed_file field to see that it works fine otherwise).

Expected behavior

Clicking insert should return you to your previous modal, with the selected image active in the image field.

@laryn
Copy link
Contributor

laryn commented Oct 1, 2023

@docwilmot One minor issue I saw in the code (an extra ;) but I can confirm that the PR fixes the issue as I experienced here, with an image field in a Paragraph being edited through the front end modal editing:

WFM!

@laryn laryn added this to the 1.26.1 milestone Oct 1, 2023
@docwilmot
Copy link
Contributor Author

Fixed stray semicolon

@laryn
Copy link
Contributor

laryn commented Oct 2, 2023

Looks good to me.

@quicksketch
Copy link
Member

@docwilmot Could you check if this suggested change is reasonable? https://github.com/backdrop/backdrop/pull/4526/files#r1348192527

@quicksketch
Copy link
Member

Thanks for the quick update @docwilmot! I re-tested and the new selector is getting used. I merged backdrop/backdrop#4526 into 1.x and 1.26.x. Thanks to you and @laryn for reviewing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants