Skip to content

Commit

Permalink
fix(ui): improve undo/redo menu item disable logic (#4609)
Browse files Browse the repository at this point in the history
  • Loading branch information
okxiaoliang4 authored Feb 11, 2025
1 parent 7db5474 commit 1edf335
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/ui/src/controllers/menus/menus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import { combineLatest, merge, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { MenuItemType } from '../../services/menu/menu';

const undoRedoDisableFactory$ = (accessor: IAccessor) => {
const undoRedoDisableFactory$ = (accessor: IAccessor, isUndo: boolean) => {
const undoRedoService = accessor.get(IUndoRedoService);
const contextService = accessor.get(IContextService);

return combineLatest([
undoRedoService.undoRedoStatus$.pipe(map((v) => v.undos <= 0)),
undoRedoService.undoRedoStatus$.pipe(map((v) => isUndo ? v.undos <= 0 : v.redos <= 0)),
merge([of({}), contextService.contextChanged$]),
]).pipe(map(([undoDisable]) => {
return undoDisable || contextService.getContextValue(EDITOR_ACTIVATED) || contextService.getContextValue(FOCUSING_FX_BAR_EDITOR);
Expand All @@ -41,7 +41,7 @@ export function UndoMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
icon: 'UndoSingle',
title: 'Undo',
tooltip: 'toolbar.undo',
disabled$: undoRedoDisableFactory$(accessor),
disabled$: undoRedoDisableFactory$(accessor, true),
};
}

Expand All @@ -52,6 +52,6 @@ export function RedoMenuItemFactory(accessor: IAccessor): IMenuButtonItem {
icon: 'RedoSingle',
title: 'Redo',
tooltip: 'toolbar.redo',
disabled$: undoRedoDisableFactory$(accessor),
disabled$: undoRedoDisableFactory$(accessor, false),
};
}

0 comments on commit 1edf335

Please sign in to comment.