Fix selecting screen on undo

This commit is contained in:
Adria Navarro 2025-01-29 10:54:20 +01:00
parent 9d5f501d2a
commit 12ab5637c1
2 changed files with 2 additions and 5 deletions

View File

@ -1437,8 +1437,6 @@ class AutomationStore extends BudiStore<AutomationState> {
this.history = createHistoryStore({
getDoc: this.actions.getDefinition.bind(this),
selectDoc: this.actions.select.bind(this),
beforeAction: () => {},
afterAction: () => {},
})
// Then wrap save and delete with history

View File

@ -58,13 +58,12 @@ export class ScreenStore extends BudiStore<ScreenState> {
getDoc: (id: string) =>
get(this.store).screens?.find(screen => screen._id === id),
selectDoc: this.select,
beforeAction: () => {},
afterAction: () => {
// Ensure a valid component is selected
if (!get(selectedComponent)) {
this.update(state => ({
componentStore.update(state => ({
...state,
selectedComponentId: get(selectedScreen)?.props._id,
selectedComponentId: get(selectedScreen)?._id,
}))
}
},