fix: apply only visible checked values when local filter has active search

When a user searches in the column filter dialog, non-visible options
retained their selected state, making it impossible to filter to just
the searched values. Now when a search query is active, only visible
checked items are included in the applied filter.
This commit is contained in:
t8y2 2026-05-14 19:19:21 +08:00
parent 6ea6e45bcd
commit c37caeba78
2 changed files with 8 additions and 2 deletions

View File

@ -5,6 +5,7 @@ mod models;
use commands::connection::AppState;
use dbx_core::storage::Storage;
use std::sync::Arc;
use std::time::Instant;
use tauri::{Manager, RunEvent};
#[cfg_attr(mobile, tauri::mobile_entry_point)]

View File

@ -391,10 +391,15 @@ function applyLocalFilter() {
if (!draft) return;
const allKeys = new Set(localFilterAllOptions.value.map((option) => option.key));
const next = { ...localColumnFilters.value };
if (draft.values.size === 0 || draft.values.size === allKeys.size) {
let selected = draft.values;
if (localFilterSearch.value.trim()) {
const visibleKeys = new Set(localFilterOptions.value.map((o) => o.key));
selected = new Set([...draft.values].filter((k) => visibleKeys.has(k)));
}
if (selected.size === 0 || selected.size === allKeys.size) {
delete next[draft.columnIndex];
} else {
next[draft.columnIndex] = new Set(draft.values);
next[draft.columnIndex] = new Set(selected);
}
localColumnFilters.value = next;
closeLocalFilter();