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

Function onMove

packages/react-aria-components/test/Treeble.test.js:140–156  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

138 let {dragAndDropHooks} = useDragAndDrop({
139 getItems: (keys, items) => items.map(item => ({'text/plain': item.value.title})),
140 onMove(e) {
141 if (e.target.dropPosition === 'before') {
142 tree.moveBefore(e.target.key, e.keys);
143 } else if (e.target.dropPosition === 'after') {
144 tree.moveAfter(e.target.key, e.keys);
145 } else if (e.target.dropPosition === 'on') {
146 // Move items to become children of the target
147 let targetNode = tree.getItem(e.target.key);
148 if (targetNode) {
149 let targetIndex = targetNode.children ? targetNode.children.length : 0;
150 let keyArray = Array.from(e.keys);
151 for (let i = 0; i < keyArray.length; i++) {
152 tree.move(keyArray[i], e.target.key, targetIndex + i);
153 }
154 }
155 }
156 }
157 });
158
159 return (

Callers

nothing calls this directly

Calls 4

moveBeforeMethod · 0.65
moveAfterMethod · 0.65
getItemMethod · 0.65
moveMethod · 0.65

Tested by

no test coverage detected