Repository navigation
fix(app): keep selected year when applying a date range in the time picker - #3356
Conversation
🦋 Changeset detectedLatest commit: 602ac39 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
PR Review
2 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 2 minor 1 posted as inline comment(s) on the changed lines. 1 listed below. Findings outside the changed lines1 minor
Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
|
Deep Review✅ No critical issues found. The change is a sound, well-scoped fix: writing an explicit year into the range text makes 🟡 P2 -- recommended
🔵 P3 nitpicks (2)
Reviewers (6): correctness, testing, maintainability, project-standards, kieran-typescript, 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 |
E2E Test Results✅ All tests passed • 407 passed • 1 skipped • 1356s
Tests ran across 4 shards in parallel. |
| } | ||
| const formatStr = | ||
| timeFormat === '24h' ? 'MMM d HH:mm:ss' : 'MMM d h:mm:ss a'; | ||
| const rangeStr = [from, to] |
There was a problem hiding this comment.
🔵 minor — Range-to-text formatting is still written out in two places, which is why this bug needed two fixes
handleSearch builds formatDate(d, {format:'withYear', clock}).join(' - ') by hand, and dateRangeToString in packages/app/src/timeQuery.ts:37 builds the same string. Add an optional clock parameter to dateRangeToString and call it here, so the range format has one source of truth and the next format change can't miss one copy.
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
|
Does this make the time range picker more verbose? I'm wondering for the user, how often do we really need to be showing the year, especially since the time input wraps now and can chew up a lot of screen real estate. |
There was a problem hiding this comment.
just caught up on the original feedback that spawned this, my preference is that we keep the year out of the output format if the time is this year. if any of the range is not this year, we can explicitly show the year.
this isn't blocking - but I think quite useful and makes sure the date picker stays compact for 99% of the time.
…3362) ## Summary Follow-up to #3356: only include the year in time picker range text when it's needed, so the input stays compact. - Range text now includes the year only when any date is in another year or in the future. Past ranges in the current year look as they did before (`Mar 3 10:00:00 - Mar 5 10:00:00`), including in the `tq` URL param. - Add `rangeNeedsExplicitYear` and `formatTimeRangeText` in `TimePicker/utils.ts`. `TimePicker` `handleSearch` and `dateRangeToString` both use `formatTimeRangeText`, so the rule and the format strings live in one place. - Update the changeset from #3356, which hasn't been released yet. - Known tradeoff: a current-year `tq` has no year, so after Jan 1 it is re-parsed into the new year. This only affects the displayed text and the picker form seed. The search itself uses the `from`/`to` timestamps in the URL. ### How to test on Vercel preview **Preview routes:** /search **Steps:** 1. Open /search and click the time picker input in the top bar. 2. In the Range tab, set the start date to `2024-03-03 10:00:00` and the end date to `2024-03-05 10:00:00`, then click Apply. 3. Verify the time input reads `Mar 3 2024 10:00:00 - Mar 5 2024 10:00:00`. 4. Open the time picker again and verify the start and end date fields still show 2024. 5. Select a range that is entirely in the current year and in the past, and click Apply. Verify the time input has no year (e.g. `Oct 1 10:00:00 - Oct 2 10:00:00`). ### References - Related PRs: #3356
Summary
Fixes the time picker resetting a selected past year to the current one after applying a range.
Mar 3 10:00:00 - Mar 5 10:00:00), then re-parsed that text withchrono-node, which guesses the year. Only ranges in the current year (and not in the future) came back correctly.Mar 3 2024 10:00:00), in bothTimePickerhandleSearchanddateRangeToString, using the existingformatDatewithYearformat. This also covers the year in thetqURL param.formatDate/dateRangeToString→parseTimeRangeInput) for past year, year boundary, current year, a future range, and both 12h and 24h clocks.Mar 3 2026 10:00:00 - Mar 5 2026 10:00:00) in the fixed 350px input.How to test on Vercel preview
Preview routes: /search
Steps:
2024-03-03 10:00:00and the end date to2024-03-05 10:00:00, then click Apply.Mar 3 2024 10:00:00 - Mar 5 2024 10:00:00and the year does not change to the current year.2026-03-15 10:00:00-2026-03-25 10:00:00, click Apply, and verify the full text, including the end time, is visible in the input without clipping.Support issue
https://github.com/ClickHouse/support-escalation/issues/8863