Preserve screen selection when renaming IDs
This commit is contained in:
parent
13f66a0bbe
commit
4616f3fa45
@ -301,11 +301,11 @@ function builderReducer(state: BuilderState, action: BuilderAction): BuilderStat
|
||||
}
|
||||
case "update-screen": {
|
||||
const { screenId, screen } = action.payload;
|
||||
return withDirty(state, {
|
||||
...state,
|
||||
screens: state.screens.map((current) =>
|
||||
current.id === screenId
|
||||
? (() => {
|
||||
let nextSelectedScreenId = state.selectedScreenId;
|
||||
|
||||
const nextScreens = state.screens.map((current) =>
|
||||
current.id === screenId
|
||||
? (() => {
|
||||
const nextScreen = {
|
||||
...current,
|
||||
...screen,
|
||||
@ -336,10 +336,19 @@ function builderReducer(state: BuilderState, action: BuilderAction): BuilderStat
|
||||
}
|
||||
}
|
||||
|
||||
if (state.selectedScreenId === current.id && nextScreen.id !== current.id) {
|
||||
nextSelectedScreenId = nextScreen.id;
|
||||
}
|
||||
|
||||
return nextScreen;
|
||||
})()
|
||||
: current
|
||||
),
|
||||
);
|
||||
|
||||
return withDirty(state, {
|
||||
...state,
|
||||
screens: nextScreens,
|
||||
selectedScreenId: nextSelectedScreenId,
|
||||
});
|
||||
}
|
||||
case "reposition-screen": {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user