From cc9d36e05623bf63a878736e705221bb126d1dbf Mon Sep 17 00:00:00 2001 From: HF Date: Sun, 25 Jul 2021 00:07:28 +0200 Subject: [PATCH] fix window order on duplication --- src/reducers/windows.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/reducers/windows.js b/src/reducers/windows.js index d046b53..309e8d3 100644 --- a/src/reducers/windows.js +++ b/src/reducers/windows.js @@ -336,12 +336,14 @@ export default function windows( } = action; const win = state.windows.find((w) => w.windowId === windowId); const newWindowId = generateWindowId(state); + const newZMax = state.zMax + 1; const { innerWidth: width, innerHeight: height, } = window; - return { + return sortWindows({ ...state, + zMax: newZMax, windows: [ ...state.windows, { @@ -349,6 +351,7 @@ export default function windows( windowId: newWindowId, xPos: Math.min(win.xPos + 15, width - SCREEN_MARGIN_EW), yPos: Math.min(win.yPos + 15, height - SCREEN_MARGIN_S), + z: newZMax, }, ], args: { @@ -357,7 +360,7 @@ export default function windows( ...state.args[windowId], }, }, - }; + }); } case 'CHANGE_WINDOW_TYPE': {