Problem/Motivation
The feature that allows users to preview media using a modal (a type of pop-up window) is not showing correctly. This could mean that when attempting to preview media files such as images, videos, and audio the expected preview within the modal window is not displaying properly. The vertical tabs look broken in the media library dialog. I have attached a screenshot for better reference.
Steps to reproduce
- Install Drupal with standard profile
- Enable media and media library modules
- Add a media field to Article content type
- Set widget for media field on Article form to Media Library
- Create new Article
- Click Add media
- You will see the vertical tabs are broken in the media library modal
Proposed resolution
Restore vertical tabs CSS custom properties to core/themes/claro/css/base/variables.pcss.css from core/themes/claro/css/components/vertical-tabs.pcss.css. See #35
Remaining tasks
Needs review
User interface changes
Before

After

API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #41 | missing_variables_in_claro-3404866-41.patch | 1.73 KB | yahyaalhamad |
| #40 | Media preview After.png | 90.52 KB | kanchan bhogade |
| #40 | Media preview before.png | 91.83 KB | kanchan bhogade |
| #39 | Screenshot at Dec 28 11-13-05.png | 245.14 KB | shweta__sharma |
| #37 | after.png | 84.93 KB | saman malik |
Issue fork drupal-3404866
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
nitin shrivastava commentedComment #4
nitin shrivastava commentedComment #5
nitin shrivastava commentedComment #6
shweta__sharma commentedHi @ Nitin shrivastava, I have checked this issue on my end the issue is replicated in my local. Also applied MR 5583 and it is perfectly applied and working fine. The media modal is themed now but according to me, this issue should be fixed in the Claro theme as Claro is a default admin theme.
The issue also exists in the claro theme as well.
Below are some screenshots:-
Oliver before the patch -
Olivero after the patch -
Claro admin theme -
Comment #7
shweta__sharma commentedComment #8
nitin shrivastava commentedComment #9
cilefen commentedThe merge request failed its pipeline.
Comment #10
nitin shrivastava commentedComment #11
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #13
gauravvvv commentedComment #14
smustgrave commentedClosed #3406681: Drupal Modal media library menu items should be designed in a better way as a duplicate.
If this is failing both themes a solution should be made to make the styling generic
Also issue summary isn't following standard template when it should
Comment #15
gauravvvv commentedThere were some variables missing in
core/themes/claro/css/theme/media-library.pcss.cssfile. I have added them in the MR.Comment #16
shweta__sharma commentedThe MR fixed the issue for Claro theme.
Comment #17
smustgrave commentedSo my comment was to see if a generic solution could be found, is this just fixing claro? What about olivero?
Should be documented in issue summary.
Comment #18
gauravvvv commentedFor Olivero, this could be a feature request rather than a bug. The Media Library dialog was never themed in Olivero. Also, could someone provide the steps to reproduce this issue without using any contrib module?
Here, I have attached a screenshot from an earlier version (10.x), and it is broken on that version as well.
Note: I am using Olivero as the admin theme to reproduce the bug. However, we do not support using Olivero as the admin theme.
Comment #19
andy-blumThe MR changes code only in Claro, so updating this to the Claro issue queue.
Comment #20
shweta__sharma commentedAgree with #18 comment as we do not support the Olivero theme as an admin theme. Updating status to NR
Thanks
Comment #21
smustgrave commentedIS still needs updating.
Comment #22
shweta__sharma commentedIssue summary updated also added standard template.
Thanks
Comment #23
shweta__sharma commentedComment #24
sandeep_k commentedVerified and tested patch MR !5583 mergeable on Drupal version-
11.0-dev. The patch was applied successfully and looks good to me.
Testing Steps:
Testing Results:
Now the media Modal broken preview issue is fixed for the Claro theme, Although the issue is still there for the Olivero theme. We can move this to RTBC as this ticket is for the Claro theme.
Comment #25
saschaeggiComment #26
saschaeggiInstead of introducing duplicates of the CSS variable defined in
vertical-tabs.csswe should aim to actually include the correct library (vertical tabs).Moving this back to needs work.
Comment #28
omkar-pd commented@saschaeggi, I've included the vertical-tabs library in media-form. Please review.
Comment #29
saschaeggi@omkar-pd thank you for working on this. I've left one suggestion to prevent loading the library generally. Otherwise this approach looks good to me 👍
Comment #30
prashant.c@saschaeggi @omkar-pd
This library
$form['#attached']['library'][] = 'claro/vertical-tabs';will only get added on the Media Library Form as it is already inside theTherefore, in my opinion we do not need any additional check here.
Thanks
Comment #31
saschaeggi@Prashant.c
We do as per default we don't have tabs in this dialog.
Comment #32
prashant.cYes, that's correct. Including the library fixes the issue but these are not vertical tabs.
Comment #33
prashant.cWe need help from some front-end dev here as adding the vertical-tabs library fixing the issue but the links/tabs within the media modal window are not vertical-tabs so IMO it is not a good idea to add this library here.
Thanks
Comment #35
godotislateDoing some archaeology:
In #3023767: Reuse or build on vertical tabs styling in media library, there was some thought of consolidating the media library menu and vertical tabs, whether through a shared CSS file, or refactoring the media library to actually use vertical tabs, but the conclusion was just to address media library menu CSS directly in the admin theme (then Seven).
In #3062751: Media and media library, the media library was re-designed in Claro. The vertical tabs CSS custom properties were from core/themes/claro/css/components/vertical-tabs.pcss.css to core/themes/claro/css/base/variables.pcss.css in this commit on 9.2.x.
In #3332729: Refactor Claro's vertical-tabs stylesheet, in the effort to refactor the vertical tabs CSS and putting component custom properties in the corresponding component CSS file, the vertical tabs custom properties were moved back from core/themes/claro/css/base/variables.pcss.css to core/themes/claro/css/components/vertical-tabs.pcss.css, without awareness that media library also depended on them.
I think it's best to move these variables back to core/themes/claro/css/base/variables.pcss.css and document why they need to live there. Pushed commit with this to the MR and rebased.
Screenshot before:


Screenshot after:
Comment #36
godotislateComment #37
saman malik commentedVerified and tested patch MR !5583 mergeable on Drupal version-
11.0-dev.
The patch was applied successfully and looks good to me.
Testing Steps:
Testing Results:
Warning/errors were not found after applying the patch and it is as per the coding standard.
Can be move to RTBC
Comment #38
saman malik commentedComment #39
shweta__sharma commentedVerified and tested MR !5583 on Drupal 11 and it is working fine. Media library tabs/links now look good. Moved Claro vertical-tabs CSS custom properties back to base variables.css
Attached after screenshot -
Moving to RTBC
Thanks
Comment #40
kanchan bhogade commentedHi, I tested MR !5583 on Drupal version 11.0
The patch was applied successfully
Testing Steps:
The patch was applied successfully, and the media Modal broken preview issue is fixed for the Claro theme.
Can move to RTBC
Comment #41
yahyaalhamadPatch for 10.2.x for a temporary fix until the new version.
Comment #42
rajab natshahFacing the same issue.
Thank you for the MR and the local patch
Comment #43
godotislateComment #44
godotislateComment #45
artemboikoTested MR #5583 on Drupal 10.2.1 looks fine, thanx
Comment #46
graber commentedBefore this lands as is, worth checking solution in https://www.drupal.org/project/drupal/issues/3416545 as well.
Comment #47
godotislate@Graber - the media type links look like vertical tabs, but aren't actually vertical tabs. Adding the
core/drupal.vertical-tablibrary fixes the CSS but adds unnecessary JS. See history of how the CSS got lost: #35Comment #48
graber commentedAhh, makes sense. We should add this css conditionally and not globally in any case to optimize. Additional library with css only maybe?
Comment #49
godotislateComment #50
graber commentedI'm quite sure a subsystem maintainer will request the same - no point loading those variables on every page, those are component variables, be it vertical tabs or media library media type links. Those variables should be included conditionally, only if one or both components are present in the current context.
Comment #51
godotislateLooks like this is a duplicate of #3394048: [Drupal 10.2 regression] Media Library "widget" View media type tabs have lost styling.