fix: undo/redo when exiting view mode (#8024)

Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
VatsalSoni_13 2024-05-19 19:24:52 +05:30 committed by GitHub
parent be4e127f6c
commit afe52c89a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 916 additions and 321 deletions

View file

@ -65,7 +65,10 @@ export const createUndoAction: ActionCreator = (history, store) => ({
PanelComponent: ({ updateData, data }) => {
const { isUndoStackEmpty } = useEmitter<HistoryChangedEvent>(
history.onHistoryChangedEmitter,
new HistoryChangedEvent(),
new HistoryChangedEvent(
history.isUndoStackEmpty,
history.isRedoStackEmpty,
),
);
return (
@ -76,6 +79,7 @@ export const createUndoAction: ActionCreator = (history, store) => ({
onClick={updateData}
size={data?.size || "medium"}
disabled={isUndoStackEmpty}
data-testid="button-undo"
/>
);
},
@ -103,7 +107,10 @@ export const createRedoAction: ActionCreator = (history, store) => ({
PanelComponent: ({ updateData, data }) => {
const { isRedoStackEmpty } = useEmitter(
history.onHistoryChangedEmitter,
new HistoryChangedEvent(),
new HistoryChangedEvent(
history.isUndoStackEmpty,
history.isRedoStackEmpty,
),
);
return (
@ -114,6 +121,7 @@ export const createRedoAction: ActionCreator = (history, store) => ({
onClick={updateData}
size={data?.size || "medium"}
disabled={isRedoStackEmpty}
data-testid="button-redo"
/>
);
},