Vanessa 2025-08-19 21:11:50 +08:00
parent 462469c490
commit 6e590f2733
3 changed files with 8 additions and 2 deletions

View file

@ -805,7 +805,9 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
return true;
}
});
let empty = false;
if (!filter) {
empty = true;
filter = {
column: colId,
operator: getDefaultOperatorByType(type),
@ -814,6 +816,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
avData.view.filters.push(filter);
}
setFilter({
empty,
filter,
protyle,
data: avData,

View file

@ -75,7 +75,8 @@ export const setFilter = async (options: {
protyle: IProtyle,
data: IAV,
target: HTMLElement,
blockElement: Element
blockElement: Element,
empty: boolean
}) => {
let rectTarget = options.target.getBoundingClientRect();
if (rectTarget.height === 0) {
@ -175,7 +176,7 @@ export const setFilter = async (options: {
return true;
}
});
if (isSame || !hasMatch) {
if (!options.empty && (isSame || !hasMatch)) {
return;
}
transaction(options.protyle, [{
@ -598,6 +599,7 @@ export const addFilter = (options: {
setPosition(options.menuElement, options.tabRect.right - options.menuElement.clientWidth, options.tabRect.bottom, options.tabRect.height);
const filterElement = options.menuElement.querySelector(`[data-id="${column.id}"] .b3-chip`) as HTMLElement;
setFilter({
empty: true,
filter,
protyle: options.protyle,
data: options.data,

View file

@ -754,6 +754,7 @@ export const openMenuPanel = (options: {
data.view.filters.find((item: IAVFilter) => {
if (item.column === target.parentElement.parentElement.dataset.id && item.value.type === target.parentElement.parentElement.dataset.filterType) {
setFilter({
empty: false,
filter: item,
protyle: options.protyle,
data,