fix(core): restore tree keyboard navigation - #273
Conversation
| #getActiveItem(e: Event, items: HTMLElement[]) { | ||
| const focusedElement = e.composedPath()[0] as HTMLElement; | ||
| return items.find(i => i === focusedElement) ? focusedElement : null; | ||
| #getKeyboardActiveItem(e: KeyboardEvent, items: HTMLElement[]) { |
There was a problem hiding this comment.
Keyboard navigation intentionally remains exact-target only. This prevents tree navigation from taking Arrow keys away from a focused nested control such as a link, button, or input.
| return target instanceof HTMLElement && items.includes(target) ? target : null; | ||
| } | ||
|
|
||
| #getPointerActiveItem(e: PointerEvent, items: HTMLElement[]) { |
There was a problem hiding this comment.
Pointer interaction may begin on nonfocusable slotted label content, so resolve the registered header through the composed path. Stop at a focusable descendant to preserve that control’s native focus.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 12 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughChangesThe changes separate pointer and keyboard list-item resolution. They update tree-node focus behavior and prevent default browser actions for Space and expansion keys while preserving selection and expansion handling. Lighthouse thresholds reflect updated bundle sizes. Tree navigation interaction
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This PR restores tree keyboard navigation and preserves focus for nested controls without introducing an actionable merge-blocking risk; it is merge-ready after normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 9 files. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
projects/core/src/menu/menu.test.lighthouse.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. projects/core/src/pagination/pagination.test.lighthouse.tsESLint skipped: the matched ESLint configuration already failed (missing-dependency). Comment |
| } | ||
| <div tabindex="0" part="_node-header"> | ||
| <slot tabindex="0" class="node-title" @click=${this.#nodeHeaderClick}></slot> | ||
| <slot class="node-title" @click=${this.#nodeHeaderClick}></slot> |
There was a problem hiding this comment.
The node header is the canonical roving-focus target. Giving the label slot its own tab stop created a competing, unmanaged focus target and left keyboard navigation unable to identify the active tree item.
| this.#isExpandable ? this._internals.states.add('is-expandable') : this._internals.states.delete('is-expandable'); | ||
| } | ||
|
|
||
| #onKeydown = (e: KeyboardEvent) => { |
There was a problem hiding this comment.
Tree selection and expansion actions occur on keyup, but browser scrolling is a keydown default. Cancel the default here while allowing the event to continue bubbling for application listeners.
64fa9e7 to
ce3c8ab
Compare
Signed-off-by: John Yanarella <jyanarella@nvidia.com>
ce3c8ab to
560ce19
Compare
|
🎉 This issue has been resolved in version 2.7.2 🎉 |
Restores tree keyboard navigation after clicking a node label. The tree header is again the single roving-focus target; pointer activation resolves noninteractive label content to that header while preserving focus for nested controls. It also cancels browser scrolling on
keydownfor tree-owned Space and expandable Left/Right commands.This restores composed-path resolution for pointer activation removed in b853178, while preserving exact-target keyboard handling so nested interactive controls retain their own focus.
Summary by CodeRabbit