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

Function moveAfter

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

moveItemsFunction · 0.85

Tested by

no test coverage detected