You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(inspector): fix picker toggle, shortcut matching and alt text status - #271
Fixes four bugs in the Frontend Inspector and the shared shortcut parser that were found in a code review of src/.
Changes
Picker (inspector/picker.js)
Toggling the inspector off while a badge is pinned left isPinned set. The next toggle-on then ignored mouse moves, so no element could be picked. toggleInspector() now uses closeInspector() when closing, like Escape does.
After hovering an element, leaving it and hovering it again, the highlight did not come back because hoveredElement was not reset. It is now cleared when the highlight is hidden.
this.floatingButton never existed (the field is _inspectorFloatButton), so the guards that ignore the floating button in handleMouseMove and handleClick never worked. They now use the real field.
Shortcut parser (shortcut-parser.js)
event.key.toLowerCase() threw for keydown events without a key (e.g. browser autofill) on every such event. A missing key now simply does not match.
On macOS, Option/Alt combined with a letter produces a special character in event.key (Option+I gives "ˆ"), so shortcuts like Cmd+Option+I never matched. When Alt/Option is part of the shortcut, letters and digits are now also matched through the physical key (event.code).
Accessibility tab (inspector/accessibility.js)
An image with alt="" (a valid decorative image) was shown as red "Missing", while an image without any alt attribute was not shown at all. Now a missing attribute shows "⚠️ Missing" and an empty one shows "Empty (decorative)".
Testing
The shortcut parser was checked with a Node script against Ctrl/Cmd+Shift+I, macOS Option+letter (including key values "ˆ" and "Dead"), events without key, a wrong physical key, function keys and none.
trunk check on the three changed files is clean.
There is no JavaScript test setup in the repository, so the picker and accessibility changes are not covered by automated tests and have not been run in a browser.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The physical-key fallback can trigger multiple actions when ordinary letters conflict with key codes and can activate shortcuts for events with a missing key.
This PR fixes Frontend Inspector picker state and image alt-text reporting, and improves the shared shortcut parser’s handling of missing keys and macOS Option shortcuts.
Changes:
Reset picker state when closing or leaving a hovered element, and correct floating-button guards.
Add physical-key matching for Alt/Option shortcuts and guard against missing key values.
Distinguish missing image alt attributes from empty decorative alt text.
File
Description
src/view/frontend/web/js/shortcut-parser.js
Adds missing-key handling and physical-key fallback for Alt/Option shortcuts.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The physical-key fallback incorrectly matches Windows AltGr input as Ctrl+Alt shortcuts, causing callers to block character entry and trigger inspector or audit actions instead.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Prevent AltGr input from matching Ctrl+Alt shortcuts
The physical-key fallback also matches AltGr input on Windows layouts, where AltGr reports both ctrlKey and altKey. For example, typing @ with German AltGr+Q (key: "@", code: "KeyQ") now matches a configured Ctrl+Alt+Q shortcut. Both callers prevent the default action when matched, so typing the character instead toggles the inspector or audits. Exclude events reporting the AltGraph modifier from this fallback while preserving macOS Option matching.
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
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.
Summary
Fixes four bugs in the Frontend Inspector and the shared shortcut parser that were found in a code review of
src/.Changes
Picker (
inspector/picker.js)isPinnedset. The next toggle-on then ignored mouse moves, so no element could be picked.toggleInspector()now usescloseInspector()when closing, like Escape does.hoveredElementwas not reset. It is now cleared when the highlight is hidden.this.floatingButtonnever existed (the field is_inspectorFloatButton), so the guards that ignore the floating button inhandleMouseMoveandhandleClicknever worked. They now use the real field.Shortcut parser (
shortcut-parser.js)event.key.toLowerCase()threw forkeydownevents without akey(e.g. browser autofill) on every such event. A missing key now simply does not match.event.key(Option+I gives "ˆ"), so shortcuts likeCmd+Option+Inever matched. When Alt/Option is part of the shortcut, letters and digits are now also matched through the physical key (event.code).Accessibility tab (
inspector/accessibility.js)alt=""(a valid decorative image) was shown as red "Missing", while an image without anyaltattribute was not shown at all. Now a missing attribute shows "Testing
keyvalues "ˆ" and "Dead"), events withoutkey, a wrong physical key, function keys andnone.trunk checkon the three changed files is clean.