Entity Browser Modal is rendered in frontend theme

Created on 14 November 2021, over 3 years ago
Updated 16 May 2024, 10 months ago

Problem/Motivation

The entity browser modal is being rendered in the front end theme.

Steps to reproduce

  1. Create a new entity browser with a modal display to users on the site.
  2. Next, you will need to create/use an entity type that is not a node. You can use the ECK module ( https://www.drupal.org/project/eck β†’ ) to create entity types if necessary. Ensure that edit pages for this entity type use the admin theme.
  3. Add an entity reference to the entity type created in the last step. The entity reference can reference users.
  4. Create a new entity browser, with a modal that displays users.
  5. Set the display of the entity reference field created in step 3 to use the entity browser created in step 4
  6. On the Admin -> Appearace page, ensure that the 'Use the administration theme when editing or creating content' is UNCHECKED
  7. Access the entity creation page for the entity type created in step 3. Trigger the modal to select users.
  8. Confirm that the front-end theme is shown in the browser

This bug is a result of the 'Use the administration theme when editing or creating content' box being unchecked. In my specific issue, this resulted in a bug that disabled the entity browser, due to JS being loaded from the front-end theme on admin pages using the modal, that then failed when the modal was closed. The system currently determines whether the admin theme should be used based on the node.settings.use_admin_theme configuration, even though the modal is being used on non-node pages.

Proposed resolution

The determination of whether to use the front or back end theme for the modal would ideally be set on the display formatter for the entity reference field using the modal. However, as the admin path is determined based on the route, and the entity browser route will be the same regardless of the entity reference field using the entity browser, this doesn't seem possible. As such, I believe a checkbox should be added to the entity browser settings page for each entity browser, determining whether that browser should use the admin route.

Remaining tasks

All

User interface changes

Adding a checkbox to entity browser settings pages titled Use admin route for this entity browser.

API changes

Set entity browser routes for each entity browser to use the admin route when the settings have indicated to do so.

Data model changes

None.

πŸ› Bug report
Status

Active

Version

2.6

Component

Miscellaneous

Created by

πŸ‡¨πŸ‡¦Canada jaypan Victoria, BC

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡§πŸ‡ͺBelgium StryKaizer Belgium

    In following issue, a fix was committed which strips the request parameters.
    #3036406: Edit button of same type doesn't work. β†’

    Drupal core uses AjaxBasePageNegotiator, which detects the active theme based on ajax requests.
    However, this negotiator needs the "ajax_page_state" request variables to be set.

    Since all request variables are unset in above issue, this breaks the core ajax theme detection, which is required when users are accessing entity browser in the frontend (e.g. from layout builder).

  • Pipeline finished with Failed
    10 months ago
    Total: 289s
    #174305
  • πŸ‡¦πŸ‡ΉAustria mvonfrie

    I'm having another variant of the problem. No matter whether displaying the entity browser as modal or iFrame, similar to the Content Browser β†’ module I disable the admin theme to be able to render the displayed entities using a template and CSS from my custom theme. I've enabled Twig debug to get information which templates are used for rendering.

    What I expect to be used is themes/custom/my_theme/templates/content/node--entity-browser.html.twig but what I get is core/themes/claro/templates/classy/content/node.html.twig. This means, when not using the admin theme (which in my case is Gin) not even the active frontend theme is used but Drupal's default theme (Claro).

  • πŸ‡ΊπŸ‡ΈUnited States loze Los Angeles

    I think there should be a config setting per entity browser allowing the admin to choose which theme to use for each EB, defaulting to the admin theme.

  • πŸ‡ΈπŸ‡ͺSweden Anskelt

    just updated the work #5 to work with 2.13.

Production build 0.71.5 2024