Repository navigation
fix(app): close the time picker on an outside click and Escape - #3818
drewhammond wants to merge 3 commits into
Conversation
The time picker stayed open when clicking outside it, for example on a search result row, and stayed above the row side panel that opened. Escape inside the dropdown didn't close it either. The picker controls its popover's opened state. With Mantine 9, a controlled popover reports outside clicks and Escape only through onChange; onClose fires after opened is already false. The picker passed only onClose, so nothing closed it. It now closes from onChange.
|
@drewhammond is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: b21c8a4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Hi @drewhammond, thanks for the pull request! Before we review code from a first-time contributor, a maintainer vouches for them, and you're not on our list yet. There's nothing else to file and this PR stays open — a maintainer will look at it, usually within a day or two, and vouch for you right here if it's a genuine attempt at the problem. To make that quick, check the PR description has:
More detail in our contributing guide. |
|
No description provided. |
PR Review
1 finding(s): 🔴 0 P0/P1 · 🟡 1 P2 · 🔵 0 P3 1 posted as inline comment(s) on the changed lines. Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides. |
…dismiss * upstream/main: fix: prevent unnecessary histogram rerender (ClickHouse#3749) fix(mcp): reject unknown tool arguments instead of ignoring them (ClickHouse#3787) feat(mcp): maxBodyChars mines only the start of each body in event_patterns and emerging_signals (ClickHouse#3742) ci: Allow AI review on forks, pin claude workflow version (ClickHouse#3817)
Deep Review✅ No critical issues found. The fix is correct for a Mantine v9 controlled 🟡 P2 -- recommended
🔵 P3 nitpicks (2)
Reviewers (9): correctness, testing, maintainability, project-standards, agent-native, learnings-researcher, kieran-typescript, julik-frontend-races, previous-comments. Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
| onClose={close} | ||
| // A controlled popover reports outside clicks and Escape (closeOnEscape) | ||
| // only through onChange; onClose fires after `opened` is already false. | ||
| onChange={next => { |
There was a problem hiding this comment.
🟡 P2 — Escape in a nested dropdown (Duration ±, time zone select, date calendar) now closes the whole picker and loses unapplied edits
Mantine's Popover.Dropdown handles closeOnEscape in onKeyDownCapture. The Duration Select, TimePickerTimeZoneSelect and the DateInputCmp popovers are all portaled into containerRef, which is inside this dropdown, so the outer handler sees their Escape first. Before this change the outer handler did nothing because onChange wasn't passed. Now it calls close(). Repro: open the picker, edit Start time, open the Duration or time zone dropdown, then press Escape to dismiss that dropdown. The whole picker closes, and the !opened effect at line 178 resets the form from dateRange, so the edits are lost. Fix: in onChange, ignore Escape that came from a nested combobox or popover, e.g. skip the close when containerRef contains an open [data-combobox-dropdown] or popover dropdown, or track the nested dropdowns' open state. Add a test that presses Escape inside the open Duration select and asserts that time-picker-popover stays mounted.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
There was a problem hiding this comment.
Won't fix: I think this is the expected behavior. It matches what clicking outside the picker or the X button does, and all three discard unapplied edits the same way.
The time picker does not close when you click outside of it. On the Search page, clicking a result row opens the row side panel and the picker stays open on top of it. Pressing Escape inside the picker does not close it either.
TimePickercontrols itsPopoverthroughopenedand only passedonClose. In Mantine 9, a controlled popover reports an outside click or Escape by callingonChange(false), and it only callsonCloseonceopenedhas actually changed to false (seeuse-popover.mjs). Since nothing ever setopenedto false, the picker stayed open. It now closes fromonChange.This probably started with the Mantine v9 upgrade in #2096, but I have not checked how v7 handled it.
The new tests in
TimePicker.test.tsxcover both an outside click and Escape.Summary
Screenshots or video
before-timepicker.mov
after-timepicker.mov
How to reproduce
Starting point: https://play.hyperdx.io/search for
main. For this branch,yarn app:dev:localconnected to the demo server (onboarding → "Connect to Demo Server").On
main:On this branch:
How to test on Vercel preview
Preview routes: /search
Steps:
data-testid="time-picker-input".data-testid="time-picker-popover"is not visible.data-testid="time-picker-input"again.time-picker-popoveron an empty spot, then press Escape.time-picker-popoveris not visible.Steps:
data-testid="time-picker-input".data-testid="time-picker-popover"is not visible.data-testid="time-picker-input"again.time-picker-popoveron an empty spot, then press Escape.time-picker-popoveris not visible.References