Avoid altering the theme registry

Created on 5 April 2024, 8 months ago
Updated 30 April 2024, 7 months ago

Problem/Motivation

It looks like the code in sticky_local_tasks_theme_registry_alter() needs to be run separately for each route, but the theme registry is built and then cached, so the dynamic aspects of that hook won't work. I was thinking it might make more sense to provide the capability to explicitly add sticky local tasks to a page, rather than hooking into the existing rendering of local tabs.

I think this ought to be a version 2.x because of the change in behavior.

Steps to reproduce

Proposed resolution

Have an option to add sticky local tasks to every page via `hook_page_bottom()` or to place a block for more fine-grained control.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom AndyF

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

Merge Requests

Comments & Activities

  • Issue created by @AndyF
  • Pipeline finished with Failed
    8 months ago
    Total: 160s
    #138767
  • Pipeline finished with Success
    8 months ago
    Total: 212s
    #138945
  • Issue was unassigned.
  • Status changed to Needs review 8 months ago
  • 🇬🇧United Kingdom AndyF

    I appreciate this is a big ol' change, I feel I probably should've been a little more constrained in my changes. But on the plus side it has some tests (:

    I was a bit surprised that I had to make the commit c26b46b8 to get the tests working on CI - I've asked about in Drupal Slack at https://drupal.slack.com/archives/C223PR743/p1712336082170709.

    Although there is a hook_update_N() I haven't tested it (not even manually). I also haven't tested it with Drupal 9 yet.

    Some other possible todos I noticed while doing this (I'm being a bit lazy by not making individual issues, but just wanted to get them down, and they're not necessarily that important).

    • Add a functional JS test that verifies links are shown/hidden on click, and that they show up on the correct side.
    • Could we add a default icon in case there isn't one? Or alternatively just not show a link in the sticky tasks?
    • When not using the block, we could provide a textarea for users to specify paths, similar to block visibility
    • We could possibly recognize entity routes when trying to select an icon, eg. entity.*.edit-form.
    • Not my strength, but I think it's better to add classes than inline styling via JS, where possible.
    • Also not my strength, but I was wondering if a transition would be a simpler way to achieve the animation than, er, an animation (:

    Thanks!

  • 🇬🇧United Kingdom AndyF

    @fjgarlin got back to me and said the change to get the tests working is all as it should be.

  • Pipeline finished with Failed
    8 months ago
    Total: 181s
    #138975
  • Pipeline finished with Failed
    8 months ago
    Total: 166s
    #138988
  • Pipeline finished with Failed
    8 months ago
    Total: 182s
    #138990
  • Status changed to Needs work 8 months ago
  • 🇬🇧United Kingdom AndyF

    I've updated the tests to cover the previous major Drupal version, and this has uncovered at the very least I shouldn't be using autowiring or we should drop support for Drupal 9.

  • Andy, thanks a lot for well a whole rewrite and tests along with it, dropping support for D8/9 is just fine for sure.

    To answer the followings:

    • Could we add a default icon in case there isn't one? Or alternatively just not show a link in the sticky tasks?
    • - Yes we should, that we should for sure, happened on a website I've seen recently.

    • When not using the block, we could provide a textarea for users to specify paths, similar to block visibility
    • - Would be a nice addition

    • We could possibly recognize entity routes when trying to select an icon, eg. entity.*.edit-form.
    • - isn't that what we are already doing? or what exactly you mean by recognize?

    • Not my strength, but I think it's better to add classes than inline styling via JS, where possible.
    • - The animations in general are not the best, it was the first draft that got stuck, yes we can/should make it more fancy.

    • Also not my strength, but I was wondering if a transition would be a simpler way to achieve the animation than, er, an animation (:
    • have to check the code, but I thought I did use transition in the animation

  • Pipeline finished with Success
    8 months ago
    Total: 454s
    #139589
  • Status changed to Needs review 8 months ago
  • 🇬🇧United Kingdom AndyF

    I've removed support for D9. Also added an optional test of the previous minor version (ie it has to be run manually), and ran that to confirm it works with D10.1.

    Still haven't tested the update hook.

  • Pipeline finished with Manual
    8 months ago
    #139590
  • 🇬🇧United Kingdom AndyF

    We could possibly recognize entity routes when trying to select an icon, eg. entity.*.edit-form.

    - isn't that what we are already doing? or what exactly you mean by recognize?

    Yeah that wasn't very clear, and you're right, what we currently do is pretty much that. I noticed that we're dong substring matching eg. on edit_form but also on webform.edit_form, and I was wondering if we could match on a regex that detects an entity route as a whole, rather than a substring match. The only real advantage of this approach though is that you can then do a little bit of extra logic to determine if a canonical route is the edit form (eg. for a media entity). Ie if the route matches entity.*.canonical then check if the route also matches entity.*.edit_form, in which case it's an , otherwise assume it's a .

    Super minor tbh.

  • thanks Andy, yeah could be useful for future possible features as well, since you are the new maintainer, feel free to tag a 2.x

  • Status changed to Fixed 7 months ago
  • 🇬🇧United Kingdom AndyF

    I tested the update from 1.x to 2.x and it successfully converted the config from the old format to the new.

  • A lot of great stuff in the new release, thanks a lot.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024