From bbef1553a0ce996f1e20afea8423fda0eb672bc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E7=86=B1?= Date: Wed, 16 Jul 2025 16:39:19 +0800 Subject: [PATCH] fix(sheets-data-validation-ui): reorder `SetCellEditVisibleOperation` command execution (#5541) --- .../src/services/dropdown-manager.service.ts | 18 +++++++++--------- .../src/views/dropdown/date-dropdown/index.tsx | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/sheets-data-validation-ui/src/services/dropdown-manager.service.ts b/packages/sheets-data-validation-ui/src/services/dropdown-manager.service.ts index ecf3da5dba..b6be4078dd 100644 --- a/packages/sheets-data-validation-ui/src/services/dropdown-manager.service.ts +++ b/packages/sheets-data-validation-ui/src/services/dropdown-manager.service.ts @@ -206,12 +206,6 @@ export class DataValidationDropdownManagerService extends Disposable { t: CellValueType.NUMBER, }, rule)) ) { - await this._commandService.executeCommand(SetCellEditVisibleOperation.id, { - visible: false, - eventType: DeviceInputEventType.Keyboard, - unitId, - keycode: KeyCode.ESC, - } as IEditorBridgeServiceVisibleParam); await this._commandService.executeCommand(SetRangeValuesCommand.id, { unitId, subUnitId, @@ -234,6 +228,12 @@ export class DataValidationDropdownManagerService extends Disposable { }, }, }); + await this._commandService.executeCommand(SetCellEditVisibleOperation.id, { + visible: false, + eventType: DeviceInputEventType.Keyboard, + unitId, + keycode: KeyCode.ESC, + } as IEditorBridgeServiceVisibleParam); return true; } else { if (this._injector.has(DataValidationRejectInputController)) { @@ -316,6 +316,7 @@ export class DataValidationDropdownManagerService extends Disposable { }, }; + this._commandService.executeCommand(SetRangeValuesCommand.id, params); if (this._editorBridgeService.isVisible().visible) { await this._commandService.executeCommand(SetCellEditVisibleOperation.id, { visible: false, @@ -324,7 +325,6 @@ export class DataValidationDropdownManagerService extends Disposable { keycode: KeyCode.ESC, } as IEditorBridgeServiceVisibleParam); } - this._commandService.executeCommand(SetRangeValuesCommand.id, params); if (multiple) { return false; @@ -382,6 +382,7 @@ export class DataValidationDropdownManagerService extends Disposable { }, }; + this._commandService.syncExecuteCommand(SetRangeValuesCommand.id, params); if (this._editorBridgeService.isVisible().visible) { this._commandService.syncExecuteCommand(SetCellEditVisibleOperation.id, { visible: false, @@ -390,7 +391,6 @@ export class DataValidationDropdownManagerService extends Disposable { keycode: KeyCode.ESC, } as IEditorBridgeServiceVisibleParam); } - this._commandService.syncExecuteCommand(SetRangeValuesCommand.id, params); return true; }; @@ -425,6 +425,7 @@ export class DataValidationDropdownManagerService extends Disposable { }, }; + this._commandService.syncExecuteCommand(SetRangeValuesCommand.id, params); if (this._editorBridgeService.isVisible().visible) { this._commandService.syncExecuteCommand(SetCellEditVisibleOperation.id, { visible: false, @@ -433,7 +434,6 @@ export class DataValidationDropdownManagerService extends Disposable { keycode: KeyCode.ESC, } as IEditorBridgeServiceVisibleParam); } - this._commandService.syncExecuteCommand(SetRangeValuesCommand.id, params); return true; }; diff --git a/packages/sheets-ui/src/views/dropdown/date-dropdown/index.tsx b/packages/sheets-ui/src/views/dropdown/date-dropdown/index.tsx index 17b2c38cd9..c3a720c3c4 100644 --- a/packages/sheets-ui/src/views/dropdown/date-dropdown/index.tsx +++ b/packages/sheets-ui/src/views/dropdown/date-dropdown/index.tsx @@ -36,11 +36,11 @@ export function DateDropdown(props: { popup: IPopup patternType !== 'time' ? dayjs() : dayjs('1900-01-01 00:00:00'), []); const date = localDate && localDate.isValid() ? localDate : defaultDate; const localeService = useDependency(LocaleService); + const handleSave = async () => { - if (!date) { - return; - } - if ((await onChange?.(date)) !== false) { + if (!date) return; + const result = await onChange?.(date); + if (result) { hideFn(); } };