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

Function moveAfter

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

Source from the content-addressed store, hash-verified

442 });
443 },
444 moveAfter(key: Key, keys: Iterable<Key>) {
445 setItems(prevState => {
446 let {items, nodeMap} = prevState;
447 let node = nodeMap.get(key);
448 if (!node) {
449 return prevState;
450 }
451 let toParentKey = node.parentKey ?? null;
452 let parent: null | TreeNode<T> = null;
453 if (toParentKey != null) {
454 parent = nodeMap.get(toParentKey) ?? null;
455 }
456 let toIndex = parent?.children ? parent.children.indexOf(node) : items.indexOf(node);
457 toIndex++;
458 return moveItems(prevState, keys, parent, toIndex, updateTree, addNode);
459 });
460 },
461 update(oldKey: Key, newValue: T) {
462 setItems(({items, nodeMap: originalMap}) =>
463 updateTree(

Callers

nothing calls this directly

Calls 2

setItemsFunction · 0.85
moveItemsFunction · 0.85

Tested by

no test coverage detected