Skip to content

fix(ui): announce and show the on or off state of toggle menu entries - #381

Open
Exeloo wants to merge 11 commits into
mainfrom
fix/menu-toggle-state
Open

Exeloo wants to merge 11 commits into
mainfrom
fix/menu-toggle-state

Conversation

@Exeloo

@Exeloo Exeloo commented Nov 29, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Closes #311

Toggle entries in menus showed no on or off state: they were plain menuitems. They now show and announce it:

manifest / MENU_ITEMS { checked: "<when clause>" } -> resolveMenu -> MenuEntry { checked: boolean }
MenuEntry { checked }               -> CheckboxItem: menuitemcheckbox, aria-checked, check icon when on
MenuEntry { checked, radio: true }  -> RadioItem:    menuitemradio, one choice among its neighbours
MenuEntry without checked           -> Item: menuitem, as before
  • Kit: MenuEntries.svelte renders the three kinds, and context-menu.svelte now uses MenuEntries (submenus included) instead of its own copy. The check slot is always reserved, so labels don't shift. The icon is aria-hidden; the state is in aria-checked.
  • Menu items: MenuItemSchema gets an optional checked when clause. resolveMenu evaluates it, and config.<setting key> reads a setting, so a plugin's toggle shows its state before the plugin activates. A clause that fails leaves the entry unchecked and warns once, instead of breaking the menu.
  • View › Dark theme: checked while a dark theme is on, through a new themeKind context key. The command title "Toggle light/dark theme" is unchanged, so the palette still finds it.
  • View › Show hidden files (file-manager): checked from the showHidden setting, also before the Files panel loads. The command has an onCommand: activation.
  • One-of-N choices are radios: the setting scope picker (settings-ui) and the game resolution menu (viewport).
  • Docs: docs/docs/plugins/manifest.mdx (the checked field, themeKind, config.<setting key>), docs/docs/editor/layout.mdx (View › Dark theme), and the Menus rule in AGENTS.md.

How do you test this PR?

  • Before (built without the change): e2e/menu-toggle.spec.ts fails: no menuitemcheckbox named "Dark theme". resolve-menu.spec.ts fails with the resolveMenu change reverted (entries have no checked).
  • After: both pass. menu-toggle.spec.ts checks "Dark theme" is aria-checked="true" (the suite runs on the dark theme) and "Show hidden files" starts at false, toggles it by click and from the keyboard (Space), reopens the menu, and restores the setting in a finally.
  • Kit tests in kit.svelte.spec.ts: checkbox and radio entries, with ArrowDown and Space on a radio entry.
  • Last round (5e9b956): packages/ui unit tests 120 passed; menu-toggle.spec.ts 2 passed; console.spec.ts --repeat-each 15 --retries 0 30 passed, 0 failed (the 30 skipped are its two "with the engine" tests); viewport.spec.ts with the engine and CLI 5 passed, 0 skipped, which runs the Resolution radio; pnpm build, pnpm lint, pnpm typecheck pass.
  • Earlier rounds also ran packages/kernel (120 passed), packages/sdk (3 passed, API snapshot unchanged) and plugins/file-manager (25 passed) unit tests. After round 1 (the radio entries), 34 e2e tests passed.
  • Manual check: open View; toggle Dark theme and Show hidden files; open a setting's scope menu.

Merge danger

  • Door: two-way. The optional checked and radio fields are additive; the role change is easy to revert.
  • Blast radius: every kit Menu and ContextMenu consumer that sets checked, including third-party plugins through the SDK kit. Their entries change role from menuitem to menuitemcheckbox (or menuitemradio with radio: true). Two View entries are renamed ("Dark theme", "Show hidden files"). No runtime dependents in other repos. The editor app deploys on merge (ADR 0006).
  • Role changes: this PR makes toggle entries menuitemcheckbox and one-of-N entries menuitemradio; fix/menubar-arrows (Arrow keys do not move between the top menus #319) makes the top-menu titles menuitem in a Menubar. The other sweep branches' specs use locators that work with or without those changes (.or(), [aria-label="Main menu"] [aria-haspopup="menu"]).
  • Merge order: apps/editor/e2e/viewport.spec.ts conflicts with fix/plugins-a11y (Small accessibility issues in the code tabs, Game screen, Packages, Problems and History #324) on adjacent lines: combine them. context-menu.svelte merges clean with fix/workbench-a11y.
  • Integration proof: a scratch branch with every editor branch of this sweep merged passed pnpm build, lint, typecheck, pnpm test --force (1014 passed, 1 skipped) and the full e2e suite with the engine (141/141, Chromium only).

Follow-up issues

Quality gate

Check Result HEAD Notes
Docs Updated 672c6b9 docs/docs/plugins/manifest.mdx, docs/docs/editor/layout.mdx, AGENTS.md, written by the producer
Correctness Pass 672c6b9 Round 1 at 4d5d54f: B1 (the scope picker became checkboxes and broke settings-ui.spec.ts), I1 (hidden files state unset before the plugin loads), fixed in 13db88b–672c6b9. Re-review: no Blocking or Important. Minors (radio Space test, warn once, e2e cleanup) fixed in 5e9b956: producer tests, not re-reviewed
Performance Pass 4d5d54f In the correctness review: one cached parseWhen per toggle on menu open. No separate performance review
Accessibility Pass 4d5d54f Minors: checked is one-way into bits-ui (the menu closes on select), Space untested (tested since 4c4021f)
Security Pass 4d5d54f In the correctness review: checked only goes through the when parser, no eval. No separate security review
Style Pass 4d5d54f lint: pass. Minor line width fixed in round 1

@Exeloo
Exeloo requested a review from Tchips46 as a code owner November 29, 2026 11:16
@github-actions github-actions Bot added documentation Improvements or additions to documentation apps:editor Related to Editor app packages:ui Related to UI package plugins:file-manager Related to File manager plugin plugins:settings-ui Related to Settings ui plugin plugins:viewport Related to Viewport plugin labels Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apps:editor Related to Editor app documentation Improvements or additions to documentation packages:ui Related to UI package plugins:file-manager Related to File manager plugin plugins:settings-ui Related to Settings ui plugin plugins:viewport Related to Viewport plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Toggle entries in menus show no on or off state

1 participant