Skip to content

Commit

Permalink
fix: undo/redo when exiting view mode (excalidraw#8024)
Browse files Browse the repository at this point in the history
Co-authored-by: dwelle <[email protected]>
  • Loading branch information
Vatsalsoni13 and dwelle authored May 19, 2024
1 parent be4e127 commit afe52c8
Show file tree
Hide file tree
Showing 3 changed files with 1,050 additions and 455 deletions.
12 changes: 10 additions & 2 deletions packages/excalidraw/actions/actionHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -76,6 +79,7 @@ export const createUndoAction: ActionCreator = (history, store) => ({
onClick={updateData}
size={data?.size || "medium"}
disabled={isUndoStackEmpty}
data-testid="button-undo"
/>
);
},
Expand Down Expand Up @@ -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 (
Expand All @@ -114,6 +121,7 @@ export const createRedoAction: ActionCreator = (history, store) => ({
onClick={updateData}
size={data?.size || "medium"}
disabled={isRedoStackEmpty}
data-testid="button-redo"
/>
);
},
Expand Down
Loading

0 comments on commit afe52c8

Please sign in to comment.