Skip to content

fix(inspector): fix picker toggle, shortcut matching and alt text status - #271

Merged
dermatz merged 2 commits into
mainfrom
fix/inspector-picker-shortcut-alt-text
Nov 6, 2026
Merged

dermatz merged 2 commits into
mainfrom
fix/inspector-picker-shortcut-alt-text

Conversation

@dermatz

@dermatz dermatz commented Nov 6, 2026

Copy link
Copy Markdown
Member

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)

  • 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.

…tatus

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 6, 2026 11:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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.

2 open issues
What changed in this PR

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.
src/​view/​frontend/​web/​js/​inspector/​picker.js Fixes toggle cleanup, hover reset, and floating-button references.
src/​view/​frontend/​web/​js/​inspector/​accessibility.js Reports missing and empty image alt attributes separately.

Review effort: Balanced

…cut matching

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 6, 2026 11:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Medium severity Prevent AltGr input from matching Ctrl+Alt shortcuts

src/​view/​frontend/​web/​js/​shortcut-parser.js:103

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.

2 resolved since last review

Review effort: Balanced

@dermatz
dermatz enabled auto-merge November 6, 2026 11:47
@dermatz
dermatz disabled auto-merge November 6, 2026 11:47
@dermatz
dermatz merged commit 45060c7 into main Nov 6, 2026
21 checks passed
@dermatz
dermatz deleted the fix/inspector-picker-shortcut-alt-text branch November 6, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants