Problem/Motivation
Currently in the core/modules/navigation/src/Attribute/TopBarItem.php attribute there is no weight property which could be used by the plugin manager to control the order of the items in each top bar regions.
Proposed resolution
- Add a weight property to Top Bar items.
- Make the plugin manager sort on this weight.
Or instead of weight, add a priority logic.
Remaining tasks
Agree on solution.
API changes
New attribute property.
Release notes snippet
| Comment | File | Size | Author |
|---|
Issue fork drupal-3538221
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:
- 3538221-be-able-to
changes, plain diff MR !12885
Comments
Comment #4
riyas_nr commentedImplemented
weightdefinition for TopBarItem plugins.Sorted plugins based on
weightin the plugin manager and added test coverage to verify correct rendering order.Comment #5
riyas_nr commentedComment #6
grimreaperThanks @riyas_nr for the MR.
Looks good!
I put a review comment and pipeline needs to pass.
Comment #7
riyas_nr commentedThanks @grimreaper for the review.
I've moved the sorting logic to the
getDefinitions()override as suggested.Comment #8
grimreaperI have tested the MR with https://git.drupalcode.org/project/sobki_profile_bootstrap/-/blob/11.0.x..., locally setting a weight to control the order to test.
It works as expected!
Also given a look at the MR, ok for me.
Now needs maintainers review.
Thanks @riyas_nr !
Comment #9
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily 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 #10
grimreaperMR rebased.
Unrelated build test failure, back to RTBC.
Comment #11
catchWasn't 100% sure about using weight here, elsewhere we're trying to move to before/after - however we already use weight in a lot of different places, and we only expect a handful of top bar items (especially shown at the same time), so I think this is fine.
Committed/pushed to 11.x, thanks!
Comment #15
grimreaperThanks for the merge!