fix: auto-open filter dropdown after adding a new filter (#23330)

* fix: auto-open-filter-dropdown

closes #23326

* coderabbit suggestion

Signed-off-by: Hemant M Mehta <[email protected]>

* coderabbit suggestion

Signed-off-by: Hemant M Mehta <[email protected]>

* removing clickable event

Signed-off-by: Hemant M Mehta <[email protected]>

* updated filters

Signed-off-by: Hemant M Mehta <[email protected]>

* fix e2e tests

---------

Signed-off-by: Hemant M Mehta <[email protected]>
Co-authored-by: Eunjae Lee <[email protected]>
This commit is contained in:
Hemant M MehtaandEunjae Lee authored and GitHub committed 2025-08-26 13:22:43 +00:00
1 parent a22ca4758c
commit af07c411ee
6 files changed
+21 -28

No files matched your search

@@ -31,7 +31,7 @@ function AddFilterButtonComponent<TData>(
ref: React.Ref<HTMLButtonElement>
) {
const { t } = useLocale();
const { activeFilters, addFilter } = useDataTable();
const { activeFilters, addFilter, filterToOpen } = useDataTable();
const [open, setOpen] = useState(false);
const filterableColumns = useFilterableColumns(table);
@@ -90,6 +90,7 @@ function AddFilterButtonComponent<TData>(
<CommandItem
key={column.id}
onSelect={() => {
if (filterToOpen) filterToOpen.current = column.id;
addFilter(column.id);
setOpen(false);
}}
@@ -7,11 +7,15 @@ export function useFilterPopoverOpen(columnId: string) {
const [open, setOpen] = useState(false);
useEffect(() => {
let timeoutId: NodeJS.Timeout | undefined;
let timeoutId: ReturnType<typeof setTimeout> | undefined;
if (filterToOpen.current === columnId) {
timeoutId = setTimeout(() => {
setOpen(true);
// Reset only if we still own the marker to avoid clobbering a newer selection.
if (filterToOpen.current === columnId) {
filterToOpen.current = undefined;
}
}, 0);
}