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

Function moveAfter

packages/react-stately/src/data/useTreeData.ts:435–451  ·  view source on GitHub ↗
(key: Key, keys: Iterable<Key>)

Source from the content-addressed store, hash-verified

433 });
434 },
435 moveAfter(key: Key, keys: Iterable<Key>) {
436 setItems(prevState => {
437 let {items, nodeMap} = prevState;
438 let node = nodeMap.get(key);
439 if (!node) {
440 return prevState;
441 }
442 let toParentKey = node.parentKey ?? null;
443 let parent: null | TreeNode<T> = null;
444 if (toParentKey != null) {
445 parent = nodeMap.get(toParentKey) ?? null;
446 }
447 let toIndex = parent?.children ? parent.children.indexOf(node) : items.indexOf(node);
448 toIndex++;
449 return moveItems(prevState, keys, parent, toIndex, updateTree, addNode);
450 });
451 },
452 update(oldKey: Key, newValue: T) {
453 setItems(({items, nodeMap: originalMap}) =>
454 updateTree(

Callers

nothing calls this directly

Calls 1

moveItemsFunction · 0.85

Tested by

no test coverage detected