Skip to content

Commit 4cdc17d

Browse files
AndyOGoLFDanLu
andauthored
fix: ref.current is not checked to be set (#1550)
* fix: ref.current is not checked to be set * Update packages/@react-aria/selection/src/useSelectableList.ts fix: check ref for nullish too Co-authored-by: Daniel Lu <[email protected]> Co-authored-by: Daniel Lu <[email protected]>
1 parent 1d1d6a6 commit 4cdc17d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export function useSelectableList(props: SelectableListOptions): SelectableListA
107107
// If not virtualized, scroll the focused element into view when the focusedKey changes.
108108
// When virtualized, Virtualizer handles this internally.
109109
useEffect(() => {
110-
if (!isVirtualized && selectionManager.focusedKey) {
110+
if (!isVirtualized && selectionManager.focusedKey && ref?.current) {
111111
let element = ref.current.querySelector(`[data-key="${selectionManager.focusedKey}"]`) as HTMLElement;
112112
if (element) {
113113
scrollIntoView(ref.current, element);

0 commit comments

Comments
 (0)