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

Function moveAfter

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

Source from the content-addressed store, hash-verified

354 });
355 },
356 moveAfter(key: Key, keys: Iterable<Key>) {
357 dispatch(state => {
358 let toIndex = state.items.findIndex(item => getKey!(item) === key);
359 if (toIndex === -1) {
360 return state;
361 }
362
363 let keyArray = Array.isArray(keys) ? keys : [...keys];
364 let indices = keyArray
365 .map(key => state.items.findIndex(item => getKey!(item) === key))
366 .sort((a, b) => a - b);
367 return move(state, indices, toIndex + 1);
368 });
369 },
370 update(key: Key, newValue: T | ((prev: T) => T)) {
371 dispatch(state => {
372 let index = state.items.findIndex(item => getKey!(item) === key);

Callers

nothing calls this directly

Calls 2

moveFunction · 0.70
sortMethod · 0.65

Tested by

no test coverage detected