Problem/Motivation

Some modules mix toolbar CSS with other CSS. It is common to override module CSS without overriding their toolbar CSS, or vice versa.

Proposed resolution

Move toolbar related CSS to [module_name].toolbar.css files. This pattern is already implemented in contextual module. Implement this into Shortcut and User modules as well.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3045467

Command icon 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

lauriii created an issue. See original summary.

lauriii’s picture

@bnjmnm on Slack

Were you interested in having the toolbar icon CSS moved to the `*.toolbar.css` file as well? The ticket mentions making this change for the User module, where this would be the only change, but also mentions matching the pattern used by Contextual, which keeps the icon CSS in its own `*.icons.theme.css` file

That is a good point. I'm wondering if it would make sense to have toolbar related icons in [modulename].toolbar.css files since you would likely only override those icons if you are restyling toolbar. I would be fine also with creating [modulename].icons.toolbar.css for toolbar specific icons. What is important is that toolbar icons shouldn't be in the [modulename].icons.css file because it is not a common scenario to override both of the module icons and the toolbar icons in the same place.

bnjmnm’s picture

Status: Active » Needs review
StatusFileSize
new14.29 KB

I went with the second suggested approach of adding [modulename].icons.toolbar.css files, as the library names that use these files would all still make sense. Otherwise, a library like drupal.user.icons would need to be renamed. I wasn't sure if renaming libraries would be disruptive to contributed modules so erred on the side of caution. If there's a preference for fewer files that can be done if renaming libraries is OK.

It seemed like Settings Tray may require this refactoring as well. There is already a settings_tray.toolbar.css file, but there is also some toolbar related css found in all the module's other css files. This has me wondering if it was intentional and thought it would be best to get input before making the change.

lauriii’s picture

Status: Needs review » Needs work
+++ b/core/themes/stable/stable.info.yml
@@ -63,6 +63,7 @@ libraries-override:
+        css/contextual.icons.toolbar.css: css/contextual/contextual.icons.toolbar.css

@@ -202,6 +203,8 @@ libraries-override:
+        css/shortcut.toolbar.css: css/shortcut/shortcut.toolbar.css
+        css/shortcut.icons.toolbar.css: css/shortcut/shortcut.icons.toolbar.css

@@ -267,6 +270,7 @@ libraries-override:
+        css/tour.toolbar.css: css/tour/tour.toolbar.css

@@ -284,7 +288,7 @@ libraries-override:
+        css/user.icons.toolbar.css: css/user/user.icons.toolbar.css

We don't want to accidentally override someones overrides. We probably should refrain from making this change in Stable at all, and only keep it in the core until Drupal 9. We should revert all CSS changes to Stable, and set these CSS files to false so that they don't get loaded in theme extending Stable.

The Settings Tray CSS is a nice catch. I think we should move those to the toolbar file as well.

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new16.26 KB
new16.34 KB
  1. Undid all changes to theme css
  2. Moved toolbar css in settings tray to its toolbar file and created icons file. It was necessary to increase the weight of those files, which is explained in a comment.
  3. Worth pointing out that I removed a @todo that referenced https://www.drupal.org/node/2784593, which was closed as a duplicate of another issue, and that issue had been closed as "Won't Fix".

Status: Needs review » Needs work

The last submitted patch, 5: 3045467-5.patch, failed testing. View results

lauriii’s picture

Status: Needs work » Needs review
StatusFileSize
new19.75 KB
new3.4 KB

This should fix the test failure.

lauriii’s picture

StatusFileSize
new19.73 KB
new410 bytes

I accidentally removed a newline. Added it back in this patch.

lauriii’s picture

huzooka’s picture

Assigned: Unassigned » huzooka
Status: Needs review » Needs work
Issue tags: +Needs reroll

During review I noticed that the patch from #8 is a bit outdated (53 offset for core/themes/stable/stable.theme).

huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
StatusFileSize
new19.88 KB
huzooka’s picture

Assigned: Unassigned » huzooka
Status: Needs review » Needs work
huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
StatusFileSize
new19.72 KB
new1.31 KB
huzooka’s picture

Status: Needs review » Needs work

Review of the re-rolled patch #13:

I think that most of the refactoring are fine. This applies to contextual, shortcut, tour and user modules.

But since I see that settings_tray gets some selector changes, I want to share my related feedback:

  1. +++ b/core/modules/settings_tray/css/settings_tray.icons.toolbar.css
    @@ -0,0 +1,22 @@
    +.toolbar-tab > .toolbar-icon.toolbar-icon-edit.toolbar-item:before {
    

    I'm sure that we want to change only the contextual toolbar item, and not every toolbar item that has the edit icon. So we should change this selector to .contextual-toolbar-tab .toolbar-icon.toolbar-icon-edit:before

  2. +++ b/core/modules/settings_tray/css/settings_tray.icons.toolbar.css
    @@ -0,0 +1,22 @@
    +.toolbar-tab > .toolbar-icon.toolbar-icon-edit.toolbar-item.is-active:before {
    

    Same situation as #1: change to .contextual-toolbar-tab .toolbar-icon.toolbar-icon-edit.is-active:before

  3. +++ b/core/modules/settings_tray/css/settings_tray.icons.toolbar.css
    @@ -0,0 +1,22 @@
    +.toolbar-tab > .toolbar-icon.toolbar-icon-edit.toolbar-item:hover:before {
    

    Same situation as #1: change to .contextual-toolbar-tab .toolbar-icon.toolbar-icon-edit:hover:before

  4. +++ b/core/modules/settings_tray/css/settings_tray.icons.toolbar.css
    @@ -0,0 +1,22 @@
    +.toolbar-tab > .toolbar-icon.toolbar-icon-edit.toolbar-item:hover > .toolbar-icon-edit:before {
    ...
    +.toolbar-tab > .button.toolbar-icon.toolbar-icon.toolbar-icon-edit:before {
    

    I cannot find elements that match these selectors, but anyway: .toolbar-icon.toolbar-icon?

  5. +++ b/core/modules/settings_tray/css/settings_tray.toolbar.css
    @@ -1,66 +1,49 @@
    +.js-settings-tray-edit-mode .toolbar-item:not(.toolbar-icon-edit) {
    ...
    +.js-settings-tray-edit-mode .toolbar-item:not(.toolbar-icon-edit) .is-active {
    

    If the tray is active, these wont be visible because every other toolbar item gets the visually-hidden class. I'd remove these.

  6. +++ b/core/modules/settings_tray/css/settings_tray.toolbar.css
    @@ -1,66 +1,49 @@
    +.toolbar-tab > .toolbar-icon.toolbar-icon-edit.toolbar-item,
    +.toolbar-tab > .toolbar-icon.toolbar-icon-edit.toolbar-item.is-active,
    +.toolbar-tab > .toolbar-icon.toolbar-icon-edit.toolbar-item:focus {
    

    Same situation as #1: change these to .toolbar .toolbar-bar .contextual-toolbar-tab .toolbar-item[.is-active||:focus] (selector structure based on the one from toolbar.theme.css)

  7. +++ b/core/modules/settings_tray/css/settings_tray.toolbar.css
    @@ -1,66 +1,49 @@
    +.toolbar-tab > .toolbar-icon.toolbar-icon-edit.toolbar-item:hover,
    +.toolbar-tab > .toolbar-icon.toolbar-icon-edit.toolbar-item.is-active {
    

    Change to .toolbar .toolbar-bar .contextual-toolbar-tab .toolbar-item[:hover||.is-active]

  8. +++ b/core/modules/settings_tray/css/settings_tray.toolbar.css
    @@ -1,66 +1,49 @@
    +.toolbar-tab > .toolbar-icon.toolbar-icon-edit.toolbar-item.is-active:hover {
    

    Change to .toolbar .toolbar-bar .contextual-toolbar-tab .toolbar-item.is-active:hover (selector structure based on the one from toolbar.theme.css)

  9. +++ b/core/modules/settings_tray/settings_tray.libraries.yml
    @@ -6,7 +6,9 @@ drupal.settings_tray:
    +      css/settings_tray.icons.toolbar.css: { weight: 200 }
    +      css/settings_tray.toolbar.css: { weight: 200 }
    

    Instead of increasing the height, we should add toolbar library as explicit dependency (because it IS a dependency imho).

vacho’s picture

Issue tags: -Needs reroll

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

sakthivel m’s picture

#13 Patch Failed

sakthivel m’s picture

Status: Needs work » Needs review
StatusFileSize
new19.67 KB

#21 Please review the patch

gauravvvv’s picture

StatusFileSize
new602 bytes
new19.69 KB

Fixed custom command failed. Attached interdiff for same.

Status: Needs review » Needs work

The last submitted patch, 22: 3045467-22.patch, failed testing. View results

sakthivel m’s picture

Status: Needs work » Needs review

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

pradipmodh13’s picture

Last patched has failed so I'm moving to needs work.

pradipmodh13’s picture

Status: Needs review » Needs work
sakthivel m’s picture

Status: Needs work » Needs review
StatusFileSize
new4.12 KB

#29 Please review the patch

sakthivel m’s picture

StatusFileSize
new19.68 KB

#30 Please review the patch

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new144 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

djsagar made their first commit to this issue’s fork.

djsagar’s picture

Getting error while applied patch #30, creating MR.

djsagar’s picture

Status: Needs work » Needs review
djsagar’s picture

Status: Needs review » Needs work

Pipeline issue need to fix so moving NW.

sakthi_dev made their first commit to this issue’s fork.

sakthi_dev’s picture

@djsagar Didn't notice that you are working on it.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.