Skip to content

Commit

Permalink
🐛 (popover) fix date popover closing when editing a filter (#3009)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatissJanis authored Jul 8, 2024
1 parent 0ee9126 commit 1e38055
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"
>
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3009.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [MatissJanis]
---

Fix datepicker closing when trying to edit a date filter

0 comments on commit 1e38055

Please sign in to comment.