Skip to content

Commit 5538b21

Browse files
committed
fix lint for real
1 parent f28fb86 commit 5538b21

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

packages/@react-aria/grid/src/useGridCell.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,13 @@ export function useGridCell<T, C extends GridCollection<T>>(props: GridCellProps
109109
});
110110

111111
let onKeyDownCapture = (e: ReactKeyboardEvent) => {
112-
if (!nodeContains(e.currentTarget, e.target as Element) || state.isKeyboardNavigationDisabled || !ref.current || !getActiveElement()) {
112+
let activeElement = getActiveElement();
113+
if (!nodeContains(e.currentTarget, e.target as Element) || state.isKeyboardNavigationDisabled || !ref.current || !activeElement) {
113114
return;
114115
}
115116

116117
let walker = getFocusableTreeWalker(ref.current);
117-
walker.currentNode = getActiveElement();
118+
walker.currentNode = activeElement;
118119

119120
switch (e.key) {
120121
case 'ArrowLeft': {

packages/@react-aria/gridlist/src/useGridListItem.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,15 @@ export function useGridListItem<T>(props: AriaGridListItemOptions, state: ListSt
131131
});
132132

133133
let onKeyDownCapture = (e: ReactKeyboardEvent) => {
134-
if (!nodeContains(e.currentTarget, e.target as Element) || !ref.current || !getActiveElement()) {
134+
let activeElement = getActiveElement();
135+
if (!nodeContains(e.currentTarget, e.target as Element) || !ref.current || !activeElement) {
135136
return;
136137
}
137138

138139
let walker = getFocusableTreeWalker(ref.current);
139-
walker.currentNode = getActiveElement();
140+
walker.currentNode = activeElement;
140141

141-
if ('expandedKeys' in state && getActiveElement() === ref.current) {
142+
if ('expandedKeys' in state && activeElement === ref.current) {
142143
if ((e.key === EXPANSION_KEYS['expand'][direction]) && state.selectionManager.focusedKey === node.key && hasChildRows && !state.expandedKeys.has(node.key)) {
143144
state.toggleKey(node.key);
144145
e.stopPropagation();
@@ -244,7 +245,8 @@ export function useGridListItem<T>(props: AriaGridListItemOptions, state: ListSt
244245
};
245246

246247
let onKeyDown = (e) => {
247-
if (!nodeContains(e.currentTarget, e.target as Element) || !ref.current || !getActiveElement()) {
248+
let activeElement = getActiveElement();
249+
if (!nodeContains(e.currentTarget, e.target as Element) || !ref.current || !activeElement) {
248250
return;
249251
}
250252

@@ -254,7 +256,7 @@ export function useGridListItem<T>(props: AriaGridListItemOptions, state: ListSt
254256
// If there is another focusable element within this item, stop propagation so the tab key
255257
// is handled by the browser and not by useSelectableCollection (which would take us out of the list).
256258
let walker = getFocusableTreeWalker(ref.current, {tabbable: true});
257-
walker.currentNode = getActiveElement();
259+
walker.currentNode = activeElement;
258260
let next = e.shiftKey ? walker.previousNode() : walker.nextNode();
259261

260262
if (next) {

packages/@react-aria/selection/src/useSelectableCollection.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ export function useSelectableCollection(options: AriaSelectableCollectionOptions
314314
// If the active element is NOT tabbable but is contained by an element that IS tabbable (aka the cell), the browser will actually move focus to
315315
// the containing element. We need to special case this so that tab will move focus out of the grid instead of looping between
316316
// focusing the containing cell and back to the non-tabbable child element
317-
if (next && (!nodeContains(next, getActiveElement()) || (getActiveElement() && !isTabbable(getActiveElement())))) {
317+
let activeElement = getActiveElement();
318+
if (next && (!nodeContains(next, activeElement) || (activeElement && !isTabbable(activeElement)))) {
318319
focusWithoutScrolling(next);
319320
}
320321
}

packages/@react-aria/table/src/useTableColumnResize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import {DOMAttributes, FocusableElement, Key, RefObject} from '@react-types/shar
1616
import {focusSafely, useInteractionModality, useKeyboard, useMove, usePress} from '@react-aria/interactions';
1717
import {getActiveElement, mergeProps, useDescription, useEffectEvent, useId} from '@react-aria/utils';
1818
import {getColumnHeaderId} from './utils';
19-
// @ts-ignore
2019
import {GridNode} from '@react-types/grid';
20+
// @ts-ignore
2121
import intlMessages from '../intl/*.json';
2222
import {TableColumnResizeState} from '@react-stately/table';
2323
import {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';

0 commit comments

Comments
 (0)