[WEB-5170] feat: navigation revamp (#8162)
This commit is contained in:
parent
37c59ef0d1
commit
4806bdf99c
110 changed files with 3789 additions and 766 deletions
|
|
@ -32,19 +32,18 @@ const moveItem = <T,>(
|
|||
|
||||
const symbolKey = Reflect.ownKeys(destination).find((key) => key.toString() === "Symbol(closestEdge)");
|
||||
const position = symbolKey ? destination[symbolKey as symbol] : "bottom"; // Add 'as symbol' to cast symbolKey to symbol
|
||||
|
||||
// Calculate final position before removing source item
|
||||
const finalIndex = position === "bottom" ? destinationIndex + 1 : destinationIndex;
|
||||
|
||||
// Adjust for the fact that we're removing the source item first
|
||||
// If source is before destination, removing it shifts everything back by 1
|
||||
const adjustedDestinationIndex = finalIndex > sourceIndex ? finalIndex - 1 : finalIndex;
|
||||
|
||||
const newData = [...data];
|
||||
const [movedItem] = newData.splice(sourceIndex, 1);
|
||||
|
||||
let adjustedDestinationIndex = destinationIndex;
|
||||
if (position === "bottom") {
|
||||
adjustedDestinationIndex++;
|
||||
}
|
||||
|
||||
// Prevent moving item out of bounds
|
||||
if (adjustedDestinationIndex > newData.length) {
|
||||
adjustedDestinationIndex = newData.length;
|
||||
}
|
||||
|
||||
// Insert at the calculated position (bounds check is implicit in splice)
|
||||
newData.splice(adjustedDestinationIndex, 0, movedItem);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue