The Entity Browser integration in CKEditor only works if the Browser is using the "iframe" display.

Replication steps:

1. Download Entity Browser, Entity Embed, and Embed dev releases
3. Run drush si standard -y; drush en entity_browser_example entity_embed -y
4. Create a new Entity Embed button (see screenshot) using the second "Test entity browser for files" (we should name this one differently, machine name is test_files1)
5. Add the button to a compatible format
7. Go to a WYSIWYG editor, try to use the browser to upload a file
8. Nothing happens on submit

iFrames seems to work just fine.

Comments

samuel.mortenson created an issue. See original summary.

slashrsm’s picture

Issue tags: +Media Initiative, +D8Media

This will be very hard to fix since entity embed already operates in a modal. What about just filtering EBs using Modal display from the configuration dropdown?

samuel.mortenson’s picture

Either that, or forcing all Entity Browsers displayed in CKEditor to use the iFrame display.

slashrsm’s picture

JamesK’s picture

#2727031: Don't use OpenModalDialogCommand for modals is the first step; it allows for both dialogs to be open at once. There are still changes required to entity_embed as well.

jelle_s’s picture

Status: Active » Needs review
StatusFileSize
new1.98 KB

This is a temporary fix that forces the display plugin to an iframe. This way you don't have to create multiple entity browsers (one as a modal that doesn't auto-open for entity reference fields and one as an iframe that does auto-open for entity_embed). Feedback welcome.

Status: Needs review » Needs work

The last submitted patch, 6: 2670016-6-entity_embed_entity_browser_force_iframe.patch, failed testing.

jelle_s’s picture

Status: Needs work » Needs review

Strange. The fail seems unrelated to the patch? Or am I missing something?

jelle_s’s picture

Doesn't seem to work yet... It opens de dialog and I see the entity browser as I expect, but when I select the entity and submit it does't do anything.

jelle_s’s picture

Status: Needs review » Needs work

I dove a bit deeper and this approach will not work. Each display plugin provides its own route, so creating one on the fly means that there's no route for it. While the modal does open this way (in an iframe) the iframe loads the wrong url (entity-browser/modal/... instead of entity-browser/iframe/...). Seems we'll have to fix the actual issue in stead of using a workaround like this.

marcoscano’s picture

Category: Bug report » Task
Issue tags: -Media Initiative

Should we close this assuming that the clarification done in #2819871: Make it clear that Embed isn't compatible with Entity Browsers that use the 'Modal' display plugin is enough?

joelhsmith’s picture

StatusFileSize
new100.42 KB
new86.53 KB

I wish we could fix it. It causes a user experience problem. Clicking on a link to an entity opens the entire website in the iframe. So you end up with all the admin nav and the whole site displaying within a site. Its annoying to a developer but I think it would be very confusing to an end-user entering content. They would probably assume the site is broke.

Side note, I would like to share a work around to this user experience issue to help with the user experience. I suggest people unlink the Entity in the View. Then add View Edit Delete links in the View.
Entity browser view.

Change those new View Edit Delete to use Rewrite and choose "Output this field as a custom link". And for Target choose "_parent". This will open the Entity in a new tab instead of inside the iframe.
Enity browser view link

anybody’s picture

I agree that a solution would be very very helpful. For example when using Entity Reference fields, the "Modal" display is much better than the iFrame. But if we'd like to use the "same" Entity Browser for that and for Entity Embed we have do duplicate them all as iFrame which is bad for maintainability, usability and manual work...

Can someone sum up what has to be done to solve this? @Jelle_S perhaps? Do you still remember?
#2727031: Don't use OpenModalDialogCommand for modals has been solved in the meantime.

I can dig deeper into this, but it would be nice to have as much information as possible to save time...

jelle_s’s picture

I never figured out what was the actual problem with the modal as I recall. What I tried in my patch is to force the iframe display in cases where the modal wouldn't work. I tried to document my findings here as much as I could but it's been a year so my memory of the actual issue is fuzzy to say the least.

Basically my patch was more of a workaround than an actual fix (and the workaround itself didn't work either).

a-fro’s picture

I agree that it's a duplicate. I also tested the patch at https://www.drupal.org/project/entity_embed/issues/2820188#comment-11994341 and confirmed that it resolves the issue.

a-fro’s picture

@marcosano and I discussed this solution along with the patch at https://www.drupal.org/project/entity_embed/issues/2820188. Patch #6 above is interesting, but we're a bit concerned that it hides the issue from the site builder. Transparency seems better (you cannot select an entity browser with a modal rather than swapping it out on the fly), which the other patch provides.

wim leers’s picture

Title: Entity Browser integration does not work with Modal displays » [entity_browser] Entity Browser integration does not work with Modal displays
Status: Needs work » Closed (duplicate)