From 6930f63152e18a065d585659fb94e039e7794c59 Mon Sep 17 00:00:00 2001 From: YuHong Date: Fri, 26 Apr 2024 20:39:18 +0800 Subject: [PATCH 1/2] fix: skeleton change will remove autofill popupmenu --- .../src/views/operate-container/AutoFillPopupMenu.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/sheets-ui/src/views/operate-container/AutoFillPopupMenu.tsx b/packages/sheets-ui/src/views/operate-container/AutoFillPopupMenu.tsx index b3de2d2fd4c..9ae5828cb0b 100644 --- a/packages/sheets-ui/src/views/operate-container/AutoFillPopupMenu.tsx +++ b/packages/sheets-ui/src/views/operate-container/AutoFillPopupMenu.tsx @@ -97,6 +97,16 @@ export const AutoFillPopupMenu: React.FC<{}> = () => { return disposable.dispose; }, [forceUpdate, commandService]); + useEffect(() => { + const disposable = toDisposable( + sheetSkeletonManagerService.currentSkeleton$.subscribe((skeleton) => { + if (skeleton) { + setAnchor({ row: -1, col: -1 }); + } + })); + return disposable.dispose; + }, [sheetSkeletonManagerService]); + useEffect(() => { const disposable = toDisposable( autoFillService.menu$.subscribe((menu) => { From 1d351d9724bb52878d98929a67fa36eda4bb6515 Mon Sep 17 00:00:00 2001 From: YuHong Date: Sun, 28 Apr 2024 17:43:47 +0800 Subject: [PATCH 2/2] fix: skeletion change will only refresh btn position --- .../operate-container/AutoFillPopupMenu.tsx | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/sheets-ui/src/views/operate-container/AutoFillPopupMenu.tsx b/packages/sheets-ui/src/views/operate-container/AutoFillPopupMenu.tsx index 9ae5828cb0b..aa80b3b1ff9 100644 --- a/packages/sheets-ui/src/views/operate-container/AutoFillPopupMenu.tsx +++ b/packages/sheets-ui/src/views/operate-container/AutoFillPopupMenu.tsx @@ -14,12 +14,12 @@ * limitations under the License. */ -import type { ICommandInfo } from '@univerjs/core'; +import type { ICommandInfo, IExecutionOptions } from '@univerjs/core'; import { ICommandService, IUniverInstanceService, LocaleService, toDisposable } from '@univerjs/core'; import { Dropdown } from '@univerjs/design'; import { IRenderManagerService } from '@univerjs/engine-render'; import { Autofill, CheckMarkSingle, MoreDownSingle } from '@univerjs/icons'; -import { MoveRangeMutation, SetWorksheetActiveOperation } from '@univerjs/sheets'; +import { InsertColMutation, InsertRowMutation, MoveColsMutation, MoveRangeMutation, MoveRowsMutation, RemoveColMutation, RemoveRowMutation, SetRangeValuesMutation, SetWorksheetActiveOperation, SetWorksheetColWidthMutation, SetWorksheetRowHeightMutation } from '@univerjs/sheets'; import { useDependency } from '@wendellhu/redi/react-bindings'; import clsx from 'clsx'; import React, { useCallback, useEffect, useState } from 'react'; @@ -84,13 +84,23 @@ export const AutoFillPopupMenu: React.FC<{}> = () => { AutoClearContentCommand.id, SetZoomRatioOperation.id, SetWorksheetActiveOperation.id, + SetRangeValuesMutation.id, MoveRangeMutation.id, + RemoveRowMutation.id, + RemoveColMutation.id, + InsertRowMutation.id, + InsertColMutation.id, + MoveRowsMutation.id, + MoveColsMutation.id, + SetWorksheetColWidthMutation.id, + SetWorksheetRowHeightMutation.id, ]; - const disposable = commandService.onCommandExecuted((command: ICommandInfo) => { + const disposable = commandService.onCommandExecuted((command: ICommandInfo, options?: IExecutionOptions) => { if (command.id === SetScrollOperation.id) { forceUpdate(); } - if (endCommands.includes(command.id)) { + const fromCollab = options?.fromCollab; + if (endCommands.includes(command.id) && !fromCollab) { setAnchor({ row: -1, col: -1 }); } }); @@ -101,11 +111,11 @@ export const AutoFillPopupMenu: React.FC<{}> = () => { const disposable = toDisposable( sheetSkeletonManagerService.currentSkeleton$.subscribe((skeleton) => { if (skeleton) { - setAnchor({ row: -1, col: -1 }); + forceUpdate(); } })); return disposable.dispose; - }, [sheetSkeletonManagerService]); + }, [sheetSkeletonManagerService, forceUpdate]); useEffect(() => { const disposable = toDisposable(