Skip to content

fix(app): close the time picker on an outside click and Escape - #3818

Open
drewhammond wants to merge 3 commits into
ClickHouse:mainfrom
drewhammond:claude/time-picker-dismiss
Open

drewhammond wants to merge 3 commits into
ClickHouse:mainfrom
drewhammond:claude/time-picker-dismiss

Conversation

@drewhammond

@drewhammond drewhammond commented Nov 24, 2026 •

Copy link
Copy Markdown

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.

TimePicker controls its Popover through opened and only passed onClose. In Mantine 9, a controlled popover reports an outside click or Escape by calling onChange(false), and it only calls onClose once opened has actually changed to false (see use-popover.mjs). Since nothing ever set opened to false, the picker stayed open. It now closes from onChange.

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.tsx cover both an outside click and Escape.

Summary

Screenshots or video

Before After
before-timepicker.mov
after-timepicker.mov

How to reproduce

Starting point: https://play.hyperdx.io/search for main. For this branch, yarn app:dev:local connected to the demo server (onboarding → "Connect to Demo Server").

On main:

  1. Click the time range input at the top of the Search page. The picker opens.
  2. Click any row in the search results. The row side panel opens and the picker stays open on top of it.
  3. Close the side panel. With the picker still open, click an empty spot inside it and press Escape. The picker stays open.

On this branch:

  1. Click the time range input. The picker opens.
  2. Click any row in the search results. The picker closes and the row side panel opens.
  3. Close the side panel and open the picker again. Click an empty spot inside it and press Escape. The picker closes.

How to test on Vercel preview

Preview routes: /search

Steps:

  1. Click the element with data-testid="time-picker-input".
  2. Click the first row in the search results table.
  3. Verify the element with data-testid="time-picker-popover" is not visible.
  4. Click the element with data-testid="time-picker-input" again.
  5. Click inside time-picker-popover on an empty spot, then press Escape.
  6. Verify time-picker-popover is not visible.

Steps:

  1. Click the element with data-testid="time-picker-input".
  2. Click the first row in the search results table.
  3. Verify the element with data-testid="time-picker-popover" is not visible.
  4. Click the element with data-testid="time-picker-input" again.
  5. Click inside time-picker-popover on an empty spot, then press Escape.
  6. Verify time-picker-popover is not visible.

References

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
drewhammond requested a review from a team as a code owner November 24, 2026 21:16
@vercel

vercel Bot commented Nov 24, 2026

Copy link
Copy Markdown

@drewhammond is attempting to deploy a commit to the HyperDX Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b21c8a4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

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

@github-actions github-actions Bot added external needs-vouch Author needs a maintainer to vouch for them labels Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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:

  • The issue it addresses (ideally one labelled Accepting PR) and why the change is needed
  • Steps to reproduce the problem and verify the fix, starting from https://play.hyperdx.io or yarn app:dev:local connected to the demo server
  • Before/after screenshots if anything in the UI changed

More detail in our contributing guide.

@github-actions

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 P0/P1 in code this PR adds or changes: fix before asking for review.
  • 🟡 P2 in code this PR changes: your call. Fix if small, otherwise reply.
  • 🔵 P3 is collapsed at the bottom: nobody needs to act on it before merge.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    priority. Reply with one sentence; if it is P0, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

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)
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

The fix is correct for a Mantine v9 controlled Popover: outside-click and closeOnEscape are reported only through onChange(false), and wiring that to close() is the right remedy. onChange(true) is safely ignored because opening stays owned by onClick={toggle} and the d hotkey. The new tests exercise the real path (a controlled popover cannot self-close, so a passing assertion proves onChange fired), and renderWithMantine is a valid global helper from setupTests.tsx. The author's prior "won't fix" on discarding unapplied edits is an explicit intent decision and is treated as resolved.

🟡 P2 -- recommended

  • packages/app/src/components/TimePicker/TimePicker.tsx:300 -- Escape pressed inside an open nested DateInput calendar or Select dropdown will likely also close the entire picker, since those are independent floating-ui popovers with no shared FloatingTree, so each handles the same document-level Escape and the newly wired onChange(false) fires on the outer popover too; previously onClose never fired, so the outer picker stayed open.
    • Fix: Stop Escape propagation at the nested DateInput/Select while its dropdown is open, or guard the outer handler to skip close() when the active element is inside a nested control, and add a test that opens a calendar, presses Escape, and asserts the picker stays open.
    • julik-frontend-races, correctness, testing
🔵 P3 nitpicks (2)
  • packages/app/src/components/TimePicker/TimePicker.tsx:350 -- Escape now closes the popover through two paths: the TextInput onKeyDown branch calls close() and closeOnEscape routes through the new onChange, leaving the explicit close() redundant (idempotent today, but able to drift if either path gains side effects).
    • Fix: Drop the redundant close() from the TextInput Escape branch and let closeOnEscape own closing, keeping only the target.blur() responsibility there.
  • packages/app/src/components/TimePicker/__tests__/TimePicker.test.tsx:93 -- The dismissal tests do not assert the picker reopens afterward or that dismissal discards unapplied edits without calling onSearch/setInputValue, so secondary guarantees of the new behavior are uncovered.
    • Fix: Capture the onSearch/setInputValue mocks and assert they are not called on dismiss, and add a case that reopens the picker after dismissal.
    • testing, maintainability

Reviewers (9): correctness, testing, maintainability, project-standards, agent-native, learnings-researcher, kieran-typescript, julik-frontend-races, previous-comments.

Testing gaps:

  • No test covers Escape inside a nested DateInput calendar / Select, the scenario most likely to expose an unwanted outer-close.
  • No regression test for the exact reported bug (picker stacking above the search-result side panel).
  • No test asserts the picker can be reopened after dismissal or that dismissal discards unapplied edits.

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 => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external needs-vouch Author needs a maintainer to vouch for them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant