Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
So when using the dialog token browser (specifically in Metatag module) the modal loads in my site's main CSS file breaking the admin theme layout. This seems to happen with or without overlay turned on.
Comment | File | Size | Author |
---|---|---|---|
#6 | 1859452-fix-dialog-page-theme.patch | 1.59 KB | Dave Reid |
#4 | token_dialog-loads-theme-styles-4.patch | 1.01 KB | kalabro |
#1 | token_dialog-loads-theme-styles_1859452.patch | 1.17 KB | jnettik |
break-with-overlay.png | 127.25 KB | jnettik | |
break-wo-overlay.png | 213.7 KB | jnettik |
Comments
Comment #1
jnettikIt seems that drupal_get_css is loading in the theme CSS because /token/tree isn't viewed as an admin page. Not sure if this is the correct approach but I added admin to the path and that seems to fix the issue for me. Patch against dev attached.
Comment #2
jm.federico CreditAttribution: jm.federico commentedThere the problem would be that when loaded on a non admin page, the admin CSS would end up breaking the default theme.
There must be a way of telling the system which CSS we need.
Comment #3
jm.federico CreditAttribution: jm.federico commentedComment #4
kalabroI suggest to check if we are in admin section or not.
Works like a charm for me:
Comment #5
yannickooThat makes sense will have a review on that later.
Comment #6
Dave ReidActually I think emulating what the ajax system does is probably a better approach since it will work with any theme.
Comment #7
Dave ReidTested #6 and it seems to work really really well. We get the added benefit of the dialog not duplicating any CSS or JS that is already included on the parent page as well!
Comment #8
kalabroWorks really fast!
Thanks, @DaveReid!
Comment #9
Dave ReidCommitted #6 without the CSS/JS additions because without using ajax_deliver() it doesn't actually do anything. At least with this quickfix we don't get any conflicts since it's loading the same files.
I created a followup at #1925688: Attempt to load dialog window using AJAX system to see if we can actually switch this dialog loading functionality to the core AJAX system which would remove the need for this 'hack'.