refactor: Make INavigable extend IFocusableNode. (#9033)

This commit is contained in:
Aaron Dodson
2025-05-12 15:46:27 -07:00
committed by GitHub
parent 77bfa5b572
commit a1be83bad8
16 changed files with 135 additions and 72 deletions

View File

@@ -4,24 +4,12 @@
* SPDX-License-Identifier: Apache-2.0
*/
import type {IFocusableNode} from './i_focusable_node.js';
/**
* Represents a UI element which can be navigated to using the keyboard.
*/
export interface INavigable<T> {
/**
* Returns whether or not this specific instance should be reachable via
* keyboard navigation.
*
* Implementors should generally return true, unless there are circumstances
* under which this item should be skipped while using keyboard navigation.
* Common examples might include being disabled, invalid, readonly, or purely
* a visual decoration. For example, while Fields are navigable, non-editable
* fields return false, since they cannot be interacted with when focused.
*
* @returns True if this element should be included in keyboard navigation.
*/
isNavigable(): boolean;
export interface INavigable<T> extends IFocusableNode {
/**
* Returns the class of this instance.
*

View File

@@ -43,4 +43,18 @@ export interface INavigationPolicy<T> {
* there is none.
*/
getPreviousSibling(current: T): INavigable<any> | null;
/**
* Returns whether or not the given instance should be reachable via keyboard
* navigation.
*
* Implementors should generally return true, unless there are circumstances
* under which this item should be skipped while using keyboard navigation.
* Common examples might include being disabled, invalid, readonly, or purely
* a visual decoration. For example, while Fields are navigable, non-editable
* fields return false, since they cannot be interacted with when focused.
*
* @returns True if this element should be included in keyboard navigation.
*/
isNavigable(current: T): boolean;
}