MCPcopy Create free account
hub / github.com/adobe/react-spectrum / isNextSelected

Function isNextSelected

packages/@react-spectrum/s2/src/TreeView.tsx:829–843  ·  view source on GitHub ↗
(id: Key | undefined, state: TreeState<unknown>)

Source from the content-addressed store, hash-verified

827}
828
829function isNextSelected(id: Key | undefined, state: TreeState<unknown>) {
830 if (id == null || !state) {
831 return false;
832 }
833 let keyAfter = state.collection.getKeyAfter(id);
834
835 // We need to skip non-item nodes because the selection manager will map non-item nodes to their parent before checking selection
836 let node = keyAfter != null ? state.collection.getItem(keyAfter) : null;
837 while (node && node.type !== 'item' && keyAfter != null) {
838 keyAfter = state.collection.getKeyAfter(keyAfter);
839 node = keyAfter != null ? state.collection.getItem(keyAfter) : null;
840 }
841
842 return keyAfter != null && state.selectionManager.isSelected(keyAfter);
843}
844
845function isPrevSelected(id: Key | undefined, state: TreeState<unknown>) {
846 if (id == null || !state) {

Callers 1

TreeViewItemContentFunction · 0.70

Calls 3

getKeyAfterMethod · 0.65
getItemMethod · 0.65
isSelectedMethod · 0.65

Tested by

no test coverage detected