fix(ui): sidebar active state desync when opening links in new tabs - #25047
Open
eduardomozart wants to merge 3 commits into
Open
fix(ui): sidebar active state desync when opening links in new tabs#25047eduardomozart wants to merge 3 commits into
eduardomozart wants to merge 3 commits into
Conversation
Fixes a visual desync where opening a sidebar menu item in a new tab (e.g. via Ctrl+Click or Cmd+Click) would incorrectly change the active state of the menu in the original tab.
Modifies templates/layout/parts/menu.html.twig to ignore modifier clicks and middle-clicks when eagerly setting the active class. Also improves accuracy of click detection by replacing a flawed className.indexOf('dropdown-item') !== false check with closest('.dropdown-item').
Fixes a visual desync where opening a sidebar menu item in a new tab (e.g. via Ctrl+Click or Cmd+Click) would incorrectly change the active state of the menu in the original tab.
Modifies templates/layout/parts/menu.html.twig to ignore modifier clicks and middle-clicks when eagerly setting the active class. Also improves accuracy of click detection by replacing a flawed className.indexOf('dropdown-item') !== false check with closest('.dropdown-item').
… into fix-issue-25046
Member
|
I cannot recreate the original issue and these changes seem to have no effect. |
Contributor
Author
|
I know it may sound like a silly question, but did you clean up the Twig cache before testing? GLPI 12 uses the same logic as GLPI 11, so it should be reproducible even in newer GLPI versions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist before requesting a review
Please delete options that are not relevant.
Description
Description
When a user opens a sidebar menu item in a new tab using a keyboard modifier (
Ctrl+ Click on Windows /Cmd+ Click on macOS) or a middle-click, the sidebar's active/selected state in the current tab immediately changes to the newly clicked item, causing a visual desync with the actual page content currently being viewed (Closes #25046).Additionally, the click detection was slightly flawed and could trigger incorrectly on inner elements (like icons or text spans) instead of the link itself.
Changes Made
templates/layout/parts/menu.html.twigto correctly identify when a link is opened in a new tab/window by checking the underlyingMouseEventfor modifier keys (ctrlKey,metaKey,shiftKey,altKey) and middle-clicks (button === 1).activeCSS class to the clicked item if the click involved a modifier key.className.indexOf('dropdown-item') !== falsecheck withclosest('.dropdown-item')to reliably detect clicks on the dropdown item or its children (icons/text).Screenshots (if appropriate):
Gravacao.de.Tela.2026-07-30.as.13.13.52.mov