🐛 (popover) fix date popover closing when editing a filter (#3009)

This commit is contained in:
Matiss Janis Aboltins
2024-07-08 19:57:00 +01:00
committed by GitHub
parent 0ee9126820
commit 1e38055376
2 changed files with 23 additions and 0 deletions

View File

@@ -18,6 +18,8 @@ import { Value } from '../rules/Value';
import { FilterEditor } from './FiltersMenu';
import { subfieldFromFilter } from './subfieldFromFilter';
let isDatepickerClick = false;
type FilterExpressionProps = {
field: string | undefined;
customName: string | undefined;
@@ -100,6 +102,21 @@ export function FilterExpression({
placement="bottom start"
isOpen={editing}
onOpenChange={() => setEditing(false)}
shouldCloseOnInteractOutside={element => {
// Datepicker selections for some reason register 2x clicks
// We want to keep the popover open after selecting a date.
// So we ignore the "close" event on selection + the subsequent event.
if (element instanceof HTMLElement && element.dataset.pikaYear) {
isDatepickerClick = true;
return false;
}
if (isDatepickerClick) {
isDatepickerClick = false;
return false;
}
return true;
}}
style={{ width: 275, padding: 15, color: theme.menuItemText }}
data-testid="filters-menu-tooltip"
>

View File

@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [MatissJanis]
---
Fix datepicker closing when trying to edit a date filter