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

Method getLastKey

packages/react-aria-components/src/Tree.tsx:178–197  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

176 }
177
178 getLastKey() {
179 // Find the deepest expanded child. We don't use collection.getLastKey() here
180 // because that will return the deepest child regardless of expandedKeys.
181 // Instead, start from the last top-level key and walk down.
182 let key = this.lastKey;
183 if (key == null) {
184 return null;
185 }
186
187 let node = this.getItem(key) as CollectionNode<T>;
188
189 while (
190 node?.lastChildKey != null &&
191 (node.type !== 'item' || this.expandedKeys.has(node.key))
192 ) {
193 node = this.getItem(node.lastChildKey) as CollectionNode<T>;
194 }
195
196 return node?.key;
197 }
198
199 getKeyAfter(key: Key) {
200 let node = this.getItem(key) as CollectionNode<T>;

Callers

nothing calls this directly

Calls 2

getItemMethod · 0.95
hasMethod · 0.65

Tested by

no test coverage detected