[WEB-5170] feat: navigation revamp (#8162)

This commit is contained in:
Anmol Singh Bhatia 2025-11-26 12:56:11 +05:30 committed by GitHub
parent 37c59ef0d1
commit 4806bdf99c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
110 changed files with 3789 additions and 766 deletions

View file

@ -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