editor: fix context menu zIndex enable states
This commit is contained in:
parent
d70c2b62ef
commit
e4b25a66a0
@ -136,7 +136,16 @@ export function ContextMenu(props: {
|
|||||||
|
|
||||||
const movableSelectionIds = selectedNodes.filter((n) => !n.locked).map((n) => n.id);
|
const movableSelectionIds = selectedNodes.filter((n) => !n.locked).map((n) => n.id);
|
||||||
const movableSet = new Set(movableSelectionIds);
|
const movableSet = new Set(movableSelectionIds);
|
||||||
const orderIds = props.nodes.map((n) => n.id);
|
|
||||||
|
// IMPORTANT: node order must reflect zIndex (back→front) rather than raw array order,
|
||||||
|
// otherwise enable/disable state for zIndex actions can get out of sync.
|
||||||
|
const orderIds = props.nodes
|
||||||
|
.map((n, index) => ({ n, index, z: n.zIndex ?? index }))
|
||||||
|
.sort((a, b) => {
|
||||||
|
if (a.z !== b.z) return a.z - b.z;
|
||||||
|
return a.index - b.index;
|
||||||
|
})
|
||||||
|
.map((e) => e.n.id);
|
||||||
|
|
||||||
const maxMovableIndex = movableSelectionIds.length
|
const maxMovableIndex = movableSelectionIds.length
|
||||||
? Math.max(...movableSelectionIds.map((id) => orderIds.indexOf(id)).filter((i) => i >= 0))
|
? Math.max(...movableSelectionIds.map((id) => orderIds.indexOf(id)).filter((i) => i >= 0))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user