Add focus management system, ModalNode, and SelectionListNode components#51
Merged
Conversation
Implement a stack-based focus management system to support modals and interactive components that need to capture keyboard input. New files: - IFocusable.cs: Interface for components that can receive focus (CanFocus, HasFocus, FocusPriority, OnFocused/OnBlurred, HandleInput) - IFocusManager.cs: Interface for managing focus state (PushFocus, PopFocus, SetFocus, ClearFocus, RouteInput) - FocusManager.cs: Stack-based implementation using BehaviorSubject for reactive focus change notifications Integration: - TerminaApplication now routes KeyPressed events through focus manager before passing to ViewModel, allowing focused components to consume input - ReactiveViewModel exposes Focus property for ViewModels to manage focus - Updated WireUp() to pass focus manager to ViewModels Testing: - Added 14 comprehensive tests for FocusManager behavior - Updated ReactiveViewModelTests to include focus manager parameter This lays the groundwork for ModalNode and SelectionListNode components.
This implements GitHub issue #43 - Modal/Overlay component for selection prompts. New Components: - ModalNode: Overlay component with configurable backdrops (Transparent, Dim, Solid), positioning (Center, Top, Bottom), borders, and Escape key dismissal - SelectionListNode<T>: Keyboard-navigable list with single/multi-select modes, number key shortcuts, Home/End navigation, scrolling, and "Other" custom input Supporting Types: - BackdropStyle, ModalPosition, SelectionMode enums - SelectionItem<T> for list items with IsSelected state Factory Methods: - Layouts.Modal() for creating modals - Layouts.SelectionList() for creating selection lists (typed and string variants) Demo Integration: - Updated Todo demo to use modal dialogs for adding new items - Two-step flow: text input modal → priority selection modal - Demonstrates modal stacking and focus management Tests: - 17 tests for ModalNode (focus, input handling, dismissal, observables) - 17 tests for SelectionListNode (navigation, selection, modes, observables) Other Changes: - Added WithChild() method to StackLayout for fluent API consistency
- Add IFocusable implementation to TextInputNode so modals can forward keyboard input to text input content - Fix SelectionListNode single mode to always select highlighted item on Enter, not just when nothing is selected - Fix "Other" option to auto-start text input when navigated to or selected via number key, providing immediate typing without needing Enter first - Render "Other" text input inline replacing the option text instead of on a separate line below - Add DeferredNode to framework for rendering nodes without owning their lifecycle (useful for modals that should not be disposed when hidden) - Update TodoListPage to use Layouts.Deferred() instead of private wrapper class - Add tests for single mode Enter behavior and Other option auto-edit
- Add ModalNode documentation covering backdrop styles, positioning, interactive content integration, and complete usage examples - Add SelectionListNode documentation covering single/multi-select modes, keyboard shortcuts, "Other" option for custom input, and typed items - Add DeferredNode documentation explaining non-owning node delegation pattern for preventing ObjectDisposedException with reactive layouts - Update components index to include all three new components - Add sidebar navigation entries in VitePress config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements GitHub issue #43 - Modal/Overlay component for selection prompts.
This PR adds a complete focus management system and new interactive components:
Key Features
ModalNode:
SelectionListNode:
Focus Management:
Focus.PushFocus(modal)/Focus.PopFocus()APIIFocusableinterface for custom interactive componentsTest plan
Closes #43