Skip to content

Commit

Permalink
fix: skeleton change will remove autofill popupmenu (#2092)
Browse files Browse the repository at this point in the history
* fix: skeleton change will remove autofill popupmenu

* fix: skeletion change will only refresh btn position
  • Loading branch information
yuhongz committed Apr 29, 2024
1 parent 6c2e1d3 commit 5b80ca7
Showing 1 changed file with 24 additions and 4 deletions.
Expand Up @@ -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';
Expand Down Expand Up @@ -84,19 +84,39 @@ 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 });
}
});
return disposable.dispose;
}, [forceUpdate, commandService]);

useEffect(() => {
const disposable = toDisposable(
sheetSkeletonManagerService.currentSkeleton$.subscribe((skeleton) => {
if (skeleton) {
forceUpdate();
}
}));
return disposable.dispose;
}, [sheetSkeletonManagerService, forceUpdate]);

useEffect(() => {
const disposable = toDisposable(
autoFillService.menu$.subscribe((menu) => {
Expand Down

0 comments on commit 5b80ca7

Please sign in to comment.