Skip to content

Commit

Permalink
fix: workaround an issue in @react-aria/selection
Browse files Browse the repository at this point in the history
  • Loading branch information
alirezamirian committed Dec 12, 2024
1 parent 05b8f53 commit c2f1fce
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/jui/src/selection/useSelectableCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,19 @@ export const useSelectableCollection: typeof useAriaSelectableCollection = (
) {
selectionManager.replaceSelection(selectionManager.focusedKey);
}
});

// Working around https://github.com/adobe/react-spectrum/issues/7512
// FIXME: remove the workaround the issue is closed
if (
selectionManager.firstSelectedKey &&
selectionManager.focusedKey == null
) {
// initialize the focusedKey so that the buggy code that mutates selection
// onFocus doesn't get to run.
selectionManager.setFocusedKey(selectionManager.firstSelectedKey);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return {
collectionProps: {
...collectionProps,
Expand Down

0 comments on commit c2f1fce

Please sign in to comment.