Skip to content

feat: replace BookChapterControl with dialog-based CommandNavigator#2131

Draft
Sebastian-ubs wants to merge 9 commits intomainfrom
feat/command-navigator-bcv-replacement
Draft

feat: replace BookChapterControl with dialog-based CommandNavigator#2131
Sebastian-ubs wants to merge 9 commits intomainfrom
feat/command-navigator-bcv-replacement

Conversation

@Sebastian-ubs
Copy link
Copy Markdown
Contributor

@Sebastian-ubs Sebastian-ubs commented Mar 24, 2026

⚠️ this is just a test and not ment to be merged
see https://discord.com/channels/892072317436448768/1485647003634499675


Summary

  • Replaces the popover-based BookChapterControl with a new CommandNavigator component using a centered modal dialog (command palette pattern, inspired by MP-BCV-control)
  • BookChapterControl is now a thin wrapper around CommandNavigator for backward compatibility — all existing consumers (toolbar, web-view, platform-scripture-editor, hello-rock3) continue to work unchanged
  • New features: direct match banners with ENTER badge, responsive chapter grid (5/8/10 cols), navigation history section, footer with context-aware hints, full keyboard navigation (Tab, Arrow keys, Escape)

Changes

File Change
command-navigator.component.tsx NEW — Core dialog-based scripture navigator
command-navigator.types.ts NEW — Props type (identical to BookChapterControlProps)
command.tsx Enhanced CommandDialog (shouldFilter prop) and CommandInput (icon prop)
book-chapter-control.component.tsx Replaced 687-line impl with thin wrapper
index.ts Added CommandDialog, CommandNavigator exports
platform-bible-toolbar.tsx Uses CommandNavigator alias

Test plan

  • Click scripture reference button in toolbar → dialog opens centered on screen
  • Type "GEN 5" → direct match banner shows "Go to Genesis 5" with ENTER badge
  • Type "genesis" → unique book match with chapter grid
  • Arrow keys navigate book list and chapter grid
  • Escape closes dialog or clears search
  • Recent searches appear when search is empty
  • Existing consumers (web-view, platform-scripture-editor, hello-rock3) still work via BookChapterControl wrapper

🤖 Generated with Claude Code


This change is Reviewable

Sebastian-ubs and others added 9 commits March 24, 2026 18:43
Replace the popover-based BookChapterControl with a new CommandNavigator
component inspired by MP-BCV-control. The new component uses a centered
modal dialog (command palette pattern) with direct match banners,
responsive chapter grid, navigation history, footer hints, and full
keyboard navigation.

- Add CommandNavigator component in platform-bible-react
- Make BookChapterControl a thin wrapper for backward compatibility
- Enhance CommandDialog with shouldFilter prop
- Enhance CommandInput with customizable icon prop
- Export CommandDialog and CommandNavigator from index.ts
- Update toolbar to use CommandNavigator

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update element identification in interaction tests to match the new
CommandNavigator implementation:
- Change CHAPTER_BUTTON_ROLE from 'option' to 'button' (chapters now use Button)
- Add { hidden: true } to trigger getByRole calls (Radix Dialog aria-hidden)
- Use querySelectorAll('[data-chapter-btn]') for chapter counting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adapt interaction tests to CommandNavigator's dialog-based patterns:
- Replace click-on-top-match with Enter keypress (banner has no onClick)
- Update text matchers from book codes to English names (JHN→John, etc.)
- Update verseNum expectations to 1 (CommandNavigator drops verse from input)
- Change single-chapter book tests to include chapter in search query
  (DC books have fetchEndChapter=-1, so chapter grid would be empty)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adapt interaction tests to CommandNavigator's dialog-based patterns:
- Replace click-on-top-match with Enter keypress (banner has no onClick)
- Verify direct match banner via ENTER badge text
- Update verseNum expectations to 1 (CommandNavigator drops verse from input)
- Change single-chapter book tests to include chapter in search query
- Wait for dialog full unmount in expectPopoverToBeClosed (fixes pointer-events timing)
- Add expectPopoverToBeClosed between Smart Parsing reopen steps
- Rework keyboard navigation: ArrowDown first to enter chapter grid
- Fix BookSearchAndNavigation: type-to-navigate instead of click-book-item
- Fix back button identification with data-chapter-btn filter

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The BookChapterControl now uses a Dialog (CommandNavigator) instead of
a Popover. Update the toolbar E2E test to:
- Use [role="dialog"] input[cmdk-input] instead of [data-radix-popper-content-wrapper] input
- Check for chapter grid buttons instead of cmdk-item (typing "Gen" triggers chapter view)
- Press Escape twice to close (first clears search, second closes dialog)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace null with undefined in useRef calls, remove non-null assertion
and as-type assertions, use querySelectorAll<HTMLElement> generics,
replace ++ with += 1, and iterate sections array instead of Object.entries.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
React's DOM ref typing requires null, not undefined. Add
no-null/no-null eslint-disable comments matching project conventions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace nested ternary with if/else for chapter button variant.
Remove non-null assertion on backButton in story test.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Sebastian-ubs
Copy link
Copy Markdown
Contributor Author

Sebastian-ubs commented Mar 26, 2026

Screenshot 2026-03-26 105427 image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant