Repository navigation
fix(keys): match desktop menu editing rules - #752
Conversation
c4d2b9a to
83df878
Compare
Linux's key path treats a key pressed with Shift alone as unmodified, so MenuShortcut now decides by the press's Control, Alt and logo modifiers rather than by whether the item's shortcut has any modifier. Windows and Linux look an item up by its shortcut's own spelling and never register an editing role's key, so a NotInText item there keeps only its own spelling from later items and an editing role keeps nothing; macOS still stops at it. Native tests on Linux and Windows press both reproductions of #710 through the backends' key paths, and the headless menu test covers them on every desktop.
Windows' native menu tests each run in a process of their own on CI, so TestMenuYieldReachesTheBindingTheMenuLeaves needs its own step.
49f2f16 to
13f7ebf
Compare
|
Reviewed. I checked the change against the Windows and Linux backends ( Rebased onto current main (c76e42d). The docs and Verification on the rebased branch:
|
Summary
Fixes #710.
driver.MenuShortcut, which the core uses to decide whether aYieldsToMenubinding stands aside and which headlessapp.Keyuses to choose a menu item, now models what the desktop menus do while a text input or web view has the focus:internal/platform/linux/input.go), so such a binding stays in the keymap and runs.NotInTextitem takes nothing and keeps its shortcut from the items after it: macOS disables it during the key press and AppKit stops at the first matching key equivalent; Windows and Linux keep the first item of each shortcut spelling (menuKeys). Off macOS only that spelling is kept, since those backends look items up by each name of the press (mod+r, thenctrl+r), and an editing role's item keeps nothing, as those backends never register it.Core keymap decisions, headless tests,
KeyOptions.YieldsToMenu's doc comment, the architecture docs and the public testing docs (en, zh) use the same rules.Targets
core,base,ui,tsx, thensgotool)Screenshots
None. This changes keyboard/menu routing.
Verification
go build ./...,go vetof the touched packages for linux, windows (amd64, 386), android/arm64 and js/wasmgo tool nsgo check -target all(the Apple mobile targets need Xcode and were skipped there; the change has no build tags)go tool nsgo test ./core,./internal/driver,./nsgotest, andgo tool nsgo test -run 'Layer|Skills|Doc' .internal/driverTestMenuShortcutEditing(table per desktop), new rows incoreTestMenuYieldFollowsTextFocus, both reproductions innsgotestTestApplicationMenuShortcutsTestMenuYieldReachesTheBindingTheMenuLeavespresses Control+R and F5 through the GTK key path; passes, and fails against main's modelTestMenuYieldReachesTheBindingTheMenuLeavespresses Control+R and F5 through the backend's shortcut path in the interactive session; passes, and fails against main's model. Added as its own CI step, as Windows' native menu tests run one per processnsgotestprobe run withgo tool nsgo test -target macos -activate(RefreshMenuNotEditingand Run, both Command+R, plus Reload F5, with yielding bindings): Command+R in a focused field runs the binding and F5 the Reload item; against main's model Command+R in the field ran nothing