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

Function findKeyForRoute

packages/@react-spectrum/s2/src/SideNav.tsx:712–719  ·  view source on GitHub ↗
(collection: Collection<Node<unknown>>, route: string)

Source from the content-addressed store, hash-verified

710// The collection key of the item whose href matches `route`, or null. getKeys() covers collapsed
711// items too, and the href is stored as a data attribute so it doesn't trigger Tree's link handling.
712function findKeyForRoute(collection: Collection<Node<unknown>>, route: string): Key | null {
713 for (let key of collection.getKeys()) {
714 if (collection.getItem(key)?.props?.href === route) {
715 return key;
716 }
717 }
718 return null;
719}
720
721// Walks up from `key` to the closest ancestor that is actually rendered (i.e. all of its ancestors
722// are expanded). Returns `key` unchanged when it is already visible. A collapsed ancestor hides

Callers 2

useRouteFocusSyncFunction · 0.85
getSelectedAncestorsFunction · 0.85

Calls 2

getKeysMethod · 0.65
getItemMethod · 0.65

Tested by

no test coverage detected