Skip to content

Commit

Permalink
Update types and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesplease committed Feb 5, 2022
1 parent f95a070 commit 4e27be0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -377,7 +377,8 @@ An object that is passed to you in the LRUD-related callbacks of a [`FocusNode`
| ----------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `key` | string | A string representing the key that was pressed. One of `"left"`, `"right"`, `"up"`, `"down"`, `"select"`, or `"back"`. |
| `isArrow` | boolean | Whether or not this key is an arrow. |
| `node` | [FocusNode](#focusnode) | The [`FocusNode`](#focusnode) that received this event. |
| `node` | [FocusNode](#focusnode) | The current [`FocusNode`](#focusnode) that received this event as the event propagates up the focus hierarchy. Analagous to [`event.currentTarget`](https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget) |
| `targetNode` | [FocusNode](#focusnode) | The leaf [`FocusNode`](#focusnode) from which this event propagated. Analagous to [`event.target`](https://developer.mozilla.org/en-US/docs/Web/API/Event/target) |
| `preventDefault` | function | Call this to stop the default behavior of the event. Commonly used to override the navigation behavior |
| `stopPropagation` | function | Call this to stop the propagation of the event. |
Expand Down
4 changes: 2 additions & 2 deletions src/lrud-input/bubble-key-input.ts
Expand Up @@ -16,7 +16,7 @@ function executeFunction(
}: {
isArrow: boolean;
key: LRUDKey;
targetNode?: Node;
targetNode: Node;
preventDefault: PreventDefault;
stopPropagation: StopPropagation;
}
Expand Down Expand Up @@ -61,7 +61,7 @@ export default function bubbleKey(focusTree: FocusStore, key: LRUDKey) {
const targetNodeId = reverseFocusHierarchy[0];

// This is the equivalent of event.target within DOM events.
const targetNode: Node | undefined = state.nodes?.[targetNodeId];
const targetNode: Node = state.nodes[targetNodeId] as Node;

reverseFocusHierarchy.forEach((focusedNodeId) => {
if (propagationStopped) {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Expand Up @@ -21,6 +21,7 @@ export type ReactNodeRef = Ref<HTMLElement>;
export interface LRUDEvent {
key: LRUDKey;
isArrow: boolean;
targetNode: Node;
node: Node;
preventDefault: () => void;
stopPropagation: () => void;
Expand Down

0 comments on commit 4e27be0

Please sign in to comment.