Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix: after modifying the value, the filter hidden state needs to be r… (#3601)
ybzkydc963b0a894e
diff --git a/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsx b/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsxindex f0a365c2bb..983280eb12 100644--- a/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsx+++ b/packages/sheets-filter-ui/src/views/components/SheetsFilterByConditionsPanel.tsx@@ -15,16 +15,16 @@*/import { LocaleService, useDependency } from '@univerjs/core';-import type { ISelectProps } from '@univerjs/design';import { Input, Radio, RadioGroup, Select } from '@univerjs/design';import { useObservable } from '@univerjs/ui';import React, { useCallback, useMemo } from 'react';+import type { ISelectProps } from '@univerjs/design';-import type { ByConditionsModel } from '../../services/sheets-filter-panel.service';-import type { FilterOperator, IFilterConditionFormParams } from '../../models/conditions';import { FilterConditionItems } from '../../models/conditions';-import styles from './index.module.less';+import type { FilterOperator, IFilterConditionFormParams } from '../../models/conditions';++import type { ByConditionsModel } from '../../services/sheets-filter-panel.service';/*** Filter by conditions.@@ -60,15 +60,17 @@ export function FilterByCondition(props: { model: ByConditionsModel }) {const shouldRenderInput = FilterConditionItems.getItemByOperator(operator).numOfParameters === 1;return (<>- { name === 'operator2' && (+ {name === 'operator2' && (<RadioGroup value={radioValue} onChange={onRadioChange}><Radio value="AND">{localeService.t('sheets-filter.panel.and')}</Radio><Radio value="OR">{localeService.t('sheets-filter.panel.or')}</Radio></RadioGroup>)}<Select value={operator} options={secondaryOptions} onChange={(operator) => onFormParamsChange({ [name]: operator as FilterOperator })} />- { shouldRenderInput && (- <Input value={val} placeholder={placeholder} onChange={(value) => onFormParamsChange({ [name === 'operator1' ? 'val1' : 'val2']: value })} />+ {shouldRenderInput && (+ <div>+ <Input value={val} placeholder={placeholder} onChange={(value) => onFormParamsChange({ [name === 'operator1' ? 'val1' : 'val2']: value })} />+ </div>)}</>);diff --git a/packages/sheets-filter-ui/src/views/render-modules/sheets-filter.render-controller.ts b/packages/sheets-filter-ui/src/views/render-modules/sheets-filter.render-controller.tsindex cdab50f6b8..bd08128b51 100644--- a/packages/sheets-filter-ui/src/views/render-modules/sheets-filter.render-controller.ts+++ b/packages/sheets-filter-ui/src/views/render-modules/sheets-filter.render-controller.ts@@ -14,18 +14,18 @@* limitations under the License.*/-import { CommandType, fromCallback, ICommandService, Inject, Injector, InterceptorEffectEnum, RxDisposable, ThemeService } from '@univerjs/core';-import { INTERCEPTOR_POINT, SheetInterceptorService } from '@univerjs/sheets';-import { FILTER_MUTATIONS, SheetsFilterService } from '@univerjs/sheets-filter';-import { getCoordByCell, ISheetSelectionRenderService, SelectionShape, SheetSkeletonManagerService } from '@univerjs/sheets-ui';-import { filter, map, of, startWith, switchMap, takeUntil, throttleTime } from 'rxjs';import type { IDisposable, IRange, Workbook } from '@univerjs/core';import type { IRenderContext, IRenderModule, SpreadsheetSkeleton } from '@univerjs/engine-render';import type { ISelectionStyle, ISheetCommandSharedParams } from '@univerjs/sheets';-import type { FilterModel } from '@univerjs/sheets-filter';-import { FILTER_ICON_PADDING, FILTER_ICON_SIZE, SheetsFilterButtonShape } from '../widgets/filter-button.shape';import type { ISheetsFilterButtonShapeProps } from '../widgets/filter-button.shape';+import { CommandType, fromCallback, ICommandService, Inject, Injector, InterceptorEffectEnum, RxDisposable, ThemeService } from '@univerjs/core';+import { INTERCEPTOR_POINT, SetRangeValuesMutation, SheetInterceptorService } from '@univerjs/sheets';+import { FILTER_MUTATIONS, SheetsFilterService } from '@univerjs/sheets-filter';++import { getCoordByCell, ISheetSelectionRenderService, SelectionShape, SheetSkeletonManagerService } from '@univerjs/sheets-ui';+import { filter, map, of, startWith, switchMap, takeUntil, throttleTime } from 'rxjs';+import { FILTER_ICON_PADDING, FILTER_ICON_SIZE, SheetsFilterButtonShape } from '../widgets/filter-button.shape';const DEFAULT_Z_INDEX = 1000;@@ -85,7 +85,7 @@ export class SheetsFilterRenderController extends RxDisposable implements IRendefilter(([command]) =>command.type === CommandType.MUTATION&& (command.params as ISheetCommandSharedParams).unitId === workbook.getUnitId()- && FILTER_MUTATIONS.has(command.id)+ && (FILTER_MUTATIONS.has(command.id) || command.id === SetRangeValuesMutation.id)),throttleTime(20, undefined, { leading: false, trailing: true }),map(getParams),diff --git a/packages/sheets-filter/src/controllers/__tests__/sheets-filter.controller.spec.ts b/packages/sheets-filter/src/controllers/__tests__/sheets-filter.controller.spec.tsindex 8be56f2b1b..db0dbfd736 100644--- a/packages/sheets-filter/src/controllers/__tests__/sheets-filter.controller.spec.ts+++ b/packages/sheets-filter/src/controllers/__tests__/sheets-filter.controller.spec.ts@@ -20,7 +20,7 @@ import type { IWorkbookData, Workbook } from '@univerjs/core';import { ICommandService, Inject, Injector, IUniverInstanceService, LocaleService, LocaleType, Plugin, RANGE_TYPE, UndoCommand, Univer, UniverInstanceType } from '@univerjs/core';import { afterEach, beforeEach, describe, expect, it } from 'vitest';import type { ISetRangeValuesMutationParams } from '@univerjs/sheets';-import { CopySheetCommand, InsertColMutation, InsertSheetMutation, MoveColsCommand, MoveColsMutation, MoveRowsCommand, MoveRowsMutation, RefRangeService, RemoveColCommand, RemoveColMutation, RemoveRowCommand, RemoveRowMutation, SetRangeValuesMutation, SetSelectionsOperation, SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';+import { CopySheetCommand, InsertColMutation, InsertSheetMutation, MoveColsCommand, MoveColsMutation, MoveRangeCommand, MoveRangeMutation, MoveRowsCommand, MoveRowsMutation, RefRangeService, RemoveColCommand, RemoveColMutation, RemoveRowCommand, RemoveRowMutation, SetRangeValuesMutation, SetSelectionsOperation, SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';import { SHEET_FILTER_SNAPSHOT_ID, SheetsFilterService } from '../../services/sheet-filter.service';import { SheetsFilterController } from '../sheets-filter.controller';import { SetSheetsFilterCriteriaMutation } from '../../commands/mutations/sheets-filter.mutation';@@ -164,6 +164,8 @@ function createFilterControllerTestBed(workbookData?: IWorkbookData) {SetRangeValuesMutation,CopySheetCommand,InsertSheetMutation,+ MoveRangeCommand,+ MoveRangeMutation,]).forEach((command) => commandService.registerCommand(command));@@ -386,4 +388,28 @@ describe('test controller of sheets filter', () => {expect(filterModel?.getFilterColumn(0)?.getColumnData()).toStrictEqual({ colId: 0, filters: { blank: true } });});});++ describe('test interceptor of move range', () => {+ it('moved range intersect with filter range should expand filter', async () => {+ const res = await commandService.executeCommand(MoveRangeCommand.id, {+ fromRange: {+ startRow: 10,+ startColumn: 7,+ endRow: 16,+ endColumn: 7,+ rangeType: 0,+ },+ toRange: {+ startRow: 4,+ startColumn: 3,+ endRow: 10,+ endColumn: 3,+ rangeType: 0,+ },+ });+ expect(res).toBeTruthy();+ expect((sheetsFilterService as SheetsFilterService).getFilterModel('test', 'sheet1')!.getRange())+ .toEqual({ startRow: 3, startColumn: 0, endRow: 10, endColumn: 5 });+ });+ });});diff --git a/packages/sheets-filter/src/controllers/sheets-filter.controller.ts b/packages/sheets-filter/src/controllers/sheets-filter.controller.tsindex 8c84d15c11..9157af4068 100644--- a/packages/sheets-filter/src/controllers/sheets-filter.controller.ts+++ b/packages/sheets-filter/src/controllers/sheets-filter.controller.ts@@ -612,6 +612,13 @@ export class SheetsFilterController extends Disposable {// redos.push({ id: ReCalcSheetsFilterMutation.id, params: { unitId, subUnitId } });// undos.push({ id: ReCalcSheetsFilterMutation.id, params: { unitId, subUnitId } });+ } else if (Rectangle.intersects(toRange, filterRange)) {+ const newFilterRange: IRange = {+ ...filterRange,+ endRow: Math.max(filterRange.endRow, toRange.endRow),+ };+ redos.push({ id: SetSheetsFilterRangeMutation.id, params: { unitId, subUnitId, range: newFilterRange } });+ undos.push({ id: SetSheetsFilterRangeMutation.id, params: { unitId, subUnitId, range: filterRange } });}return {redos,