Use single openMenu state for RepoToolbar menus #54

Merged
Christoph merged 1 commit from UI_UX into main 2026-09-26 21:31:27 +00:00
Owner

This change refactors src/lib/RepoToolbar.svelte to replace the two boolean menu states (historyOpen, syncOpen) with a single union-typed openMenu: "history" | "sync" | null. Event handlers, conditionals and attributes were updated so menu visibility is driven from that single state.

Key behavior and implementation changes

  • Replaced let historyOpen = false; let syncOpen = false; with let openMenu: "history" | "sync" | null = null;.
  • Menu toggles now set openMenu to the corresponding string or to null to close (e.g. openMenu = openMenu === "sync" ? null : "sync").
  • Menu rendering conditionals changed to {:if openMenu === "sync"} / {:if openMenu === "history"}.
  • Menu-item click handlers now close the menu by setting openMenu = null before calling callbacks (onFetchPrune, onForcePush, onSyncOptions, onOpenLfs, etc.).
  • Global handlers updated to clear openMenu:
    • Clicking outside the toolbar sets openMenu = null.
    • Pressing Escape stops propagation and sets openMenu = null when any menu is open.
  • aria-expanded and class:active bindings were switched to check openMenu === "..." to keep accessibility state and styling consistent.

Summary

The visible outcome is unchanged UI behavior but with a single source of truth for which toolbar menu is open. At runtime only one menu can be open at a time; clicking outside or pressing Escape closes the open menu. There are no changes to public props or callback signatures.

Testing

No test execution results were provided.

Recommended quick checks for the reviewer

  1. In the running app, verify toggling the Sync and History menu buttons: only one menu should be open at a time, clicking a button toggles that menu, and clicking the other button opens the other menu and closes the previous one.
  2. Verify keyboard and focus behavior: pressing Escape closes an open menu; clicking outside the toolbar closes an open menu.
  3. Confirm aria-expanded on each trigger reflects the menu state (true when that menu is open, otherwise absent/false).
  4. Search the codebase for any remaining uses of historyOpen or syncOpen to ensure no references were left behind.

Compatibility / Risks

  • This is an internal UI state refactor. There are no API changes for consumers (props/callbacks unchanged).
  • Risk: ensure no external code relied on historyOpen/syncOpen (unlikely since they were internal). Also verify keyboard and screen-reader behavior remains correct after the binding changes.

Reviewer action

  • Review the updated handlers and bindings in src/lib/RepoToolbar.svelte for any missed references or regressions in accessibility attributes and ensure the suggested checks pass in the running app.
This change refactors `src/lib/RepoToolbar.svelte` to replace the two boolean menu states (`historyOpen`, `syncOpen`) with a single union-typed `openMenu: "history" | "sync" | null`. Event handlers, conditionals and attributes were updated so menu visibility is driven from that single state. Key behavior and implementation changes - Replaced `let historyOpen = false; let syncOpen = false;` with `let openMenu: "history" | "sync" | null = null;`. - Menu toggles now set `openMenu` to the corresponding string or to `null` to close (e.g. `openMenu = openMenu === "sync" ? null : "sync"`). - Menu rendering conditionals changed to `{:if openMenu === "sync"}` / `{:if openMenu === "history"}`. - Menu-item click handlers now close the menu by setting `openMenu = null` before calling callbacks (`onFetchPrune`, `onForcePush`, `onSyncOptions`, `onOpenLfs`, etc.). - Global handlers updated to clear `openMenu`: - Clicking outside the toolbar sets `openMenu = null`. - Pressing Escape stops propagation and sets `openMenu = null` when any menu is open. - `aria-expanded` and `class:active` bindings were switched to check `openMenu === "..."` to keep accessibility state and styling consistent. Summary The visible outcome is unchanged UI behavior but with a single source of truth for which toolbar menu is open. At runtime only one menu can be open at a time; clicking outside or pressing Escape closes the open menu. There are no changes to public props or callback signatures. Testing No test execution results were provided. Recommended quick checks for the reviewer 1. In the running app, verify toggling the Sync and History menu buttons: only one menu should be open at a time, clicking a button toggles that menu, and clicking the other button opens the other menu and closes the previous one. 2. Verify keyboard and focus behavior: pressing Escape closes an open menu; clicking outside the toolbar closes an open menu. 3. Confirm `aria-expanded` on each trigger reflects the menu state (`true` when that menu is open, otherwise absent/`false`). 4. Search the codebase for any remaining uses of `historyOpen` or `syncOpen` to ensure no references were left behind. Compatibility / Risks - This is an internal UI state refactor. There are no API changes for consumers (props/callbacks unchanged). - Risk: ensure no external code relied on `historyOpen`/`syncOpen` (unlikely since they were internal). Also verify keyboard and screen-reader behavior remains correct after the binding changes. Reviewer action - Review the updated handlers and bindings in `src/lib/RepoToolbar.svelte` for any missed references or regressions in accessibility attributes and ensure the suggested checks pass in the running app.
Consolidates the previous historyOpen and syncOpen booleans into a single
union-typed openMenu ("history" | "sync" | null). Menu toggles, outside-click
handler, Escape key handling and menu-item clicks now set/clear openMenu,
and aria-expanded / class bindings were updated to reference openMenu.

No user-facing behavior changes intended beyond ensuring only one menu can be
open at a time and simplifying the event-handling logic.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Christoph/Gitty!54
No description provided.