Skip to content

Conversation

@pedrobonamin
Copy link
Contributor

@pedrobonamin pedrobonamin commented Nov 24, 2025

Description

This PR fixes 4 issues found in the date time input.

SAPP-3184 - inconsistent time in time input

If a date is selected on any day in the future, the timestamp shows 00:000Z for the seconds. It looks like this:

"datetime": "2025-10-22T14:10:00.000Z"
If a later time is selected on the current day, it appears like this:

"datetime": "2025-10-09T09:20:52.718Z"
I found this to be happening because of how we set the initial values for the time input, we use new Date() which will default to use the current seconds and miliseconds, once set, there is no way to change if it is not exposed as part of the date time format. This change, prevents this from happening and doesn't set seconds and miliseconds in the time input for the initial value

timeStep was not respected

fixes sanity-io/ui#2137
fixes #11003

Pass the timeStep property to the time input, we are multiplying it by 60 because our docs indicates that this time is set in minutes, not seconds like the one in the time input. To support existing behaviors we are multiplying that value by 60.
This doesn't update the UI that is rendered when the user clicks in the input, but it is respected natively by the browsers when using arrow up and down, and it also validates the value and sets the closes value to the time selected, so, if you have a timeStep of 10 minutes and select 11:14 it will set the time to 11:10 .

Example with 15 minutes time step

  • Using arrows up and down works as expected.
  • Selecting a minute which is not a valid step, won't update the input value.
Screen.Recording.2025-11-24.at.15.08.07.mov

Delayed on change

We were using for the time input a lazy text input, this has the downside that the change is triggered only on blur of the input, which could cause users to lose the values they have updated if they close the calendar before triggering an onBlur action, which is not ideal and produces an unexpected behavior
This PR updates this input to use a normal text input, I think there is no real need to use here a lazy because the changes will not happen frequently, given the user needs to select the time in the input.

Now, each change in the hours - minute selector is propagated immediately

Screen.Recording.2025-11-24.at.15.11.10.mov

Invalid date time value was propagated from the time selector

When selecting a time which was invalid and blurring the input, that value was propagated up and inside releases it made the releases tool crash, this is now fixed by checking for the existence of the value before propagating it up.

Issue example:

Screen.Recording.2025-11-24.at.15.14.15.mov

What to review

Is the change from LazyTextInput to TextInput bad?
Is there any gotcha we can consider for the miliseconds update? Should we also make the same change in the set to current time button?

Testing

Visit the studio in https://test-studio-eoojv5grb.sanity.dev/test/structure/input-standard;datetimeTest;9bc2cd38-496b-4014-befc-c0c9bebbce9b and try the changes in the time inputs components.

Notes for release

Fixes inconsistent second and milliseconds in the time input initial value.
Restore support for time step in the time input
Fixes an issue in where in some cases the releases tool could crash when doing changes in the time input

@pedrobonamin pedrobonamin requested a review from a team as a code owner November 24, 2025 10:36
@pedrobonamin pedrobonamin requested review from juice49 and removed request for a team November 24, 2025 10:36
@vercel
Copy link

vercel bot commented Nov 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
page-building-studio Ready Ready Preview Comment Nov 24, 2025 2:54pm
test-studio Ready Ready Preview Comment Nov 24, 2025 2:54pm
3 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
e2e-studio Ignored Ignored Nov 24, 2025 2:54pm
studio-workshop Ignored Ignored Preview Nov 24, 2025 2:54pm
test-next-studio Ignored Ignored Nov 24, 2025 2:54pm

@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2025

🧪 E2E Preview environment

🔑 Environment Variables for Local Testing

This is the preview URL for the E2E tests: https://e2e-studio-2zvnf95vz.sanity.dev

To run the E2E tests locally, you can use the following environment variables, then run pnpm test:e2e --ui to open the Playwright test runner.

💬 Remember to build the project first with pnpm build:e2e.

  SANITY_E2E_PROJECT_ID=ittbm412
  SANITY_E2E_BASE_URL=https://e2e-studio-2zvnf95vz.sanity.dev
  SANITY_E2E_DATASET="update depending the project you want to test (pr-11233-chromium-19638388011 || pr-11233-firefox-19638388011 )"
  SANITY_E2E_DATASET_CHROMIUM=pr-11233-chromium-19638388011
  SANITY_E2E_DATASET_FIREFOX=pr-11233-firefox-19638388011

@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2025

📊 Playwright Test Report

Download Full E2E Report

This report contains test results, including videos of failing tests.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2025

⚡️ Editor Performance Report

Updated Mon, 24 Nov 2025 15:06:15 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 24.7 efps (41ms) 26.3 efps (38ms) -3ms (-6.2%)
article (body) 38.8 efps (26ms) 37.5 efps (27ms) +1ms (+3.5%)
article (string inside object) 29.0 efps (35ms) 27.8 efps (36ms) +2ms (+4.3%)
article (string inside array) 26.0 efps (39ms) 25.6 efps (39ms) +1ms (+1.3%)
recipe (name) 58.8 efps (17ms) 55.6 efps (18ms) +1ms (+5.9%)
recipe (description) 71.4 efps (14ms) 71.4 efps (14ms) +0ms (-/-%)
recipe (instructions) 99.9+ efps (5ms) 99.9+ efps (5ms) +0ms (-/-%)
singleString (stringField) 76.9 efps (13ms) 66.7 efps (15ms) +2ms (-/-%)
synthetic (title) 17.4 efps (58ms) 17.1 efps (59ms) +1ms (+1.7%)
synthetic (string inside object) 17.5 efps (57ms) 18.5 efps (54ms) -3ms (-5.3%)

efps — editor "frames per second". The number of updates assumed to be possible within a second.

Derived from input latency. efps = 1000 / input_latency

Detailed information

🏠 Reference result

The performance result of sanity@latest

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 41ms 54ms 81ms 119ms 51ms 10.4s
article (body) 26ms 30ms 78ms 132ms 144ms 6.1s
article (string inside object) 35ms 38ms 41ms 83ms 0ms 5.7s
article (string inside array) 39ms 46ms 61ms 90ms 11ms 6.1s
recipe (name) 17ms 22ms 26ms 41ms 0ms 6.9s
recipe (description) 14ms 17ms 20ms 31ms 0ms 4.0s
recipe (instructions) 5ms 9ms 11ms 23ms 0ms 3.0s
singleString (stringField) 13ms 15ms 18ms 18ms 0ms 5.9s
synthetic (title) 58ms 60ms 69ms 138ms 278ms 15.0s
synthetic (string inside object) 57ms 59ms 67ms 267ms 556ms 7.8s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 38ms 42ms 80ms 125ms 46ms 10.4s
article (body) 27ms 30ms 79ms 112ms 70ms 5.9s
article (string inside object) 36ms 40ms 59ms 85ms 7ms 5.8s
article (string inside array) 39ms 42ms 57ms 99ms 0ms 6.1s
recipe (name) 18ms 22ms 26ms 40ms 0ms 6.9s
recipe (description) 14ms 17ms 21ms 41ms 0ms 4.1s
recipe (instructions) 5ms 9ms 10ms 12ms 0ms 2.9s
singleString (stringField) 15ms 17ms 21ms 34ms 0ms 6.1s
synthetic (title) 59ms 62ms 83ms 180ms 257ms 15.1s
synthetic (string inside object) 54ms 56ms 78ms 122ms 113ms 7.8s

📚 Glossary

column definitions

  • benchmark — the name of the test, e.g. "article", followed by the label of the field being measured, e.g. "(title)".
  • latency — the time between when a key was pressed and when it was rendered. derived from a set of samples. the median (p50) is shown to show the most common latency.
  • p75 — the 75th percentile of the input latency in the test run. 75% of the sampled inputs in this benchmark were processed faster than this value. this provides insight into the upper range of typical performance.
  • p90 — the 90th percentile of the input latency in the test run. 90% of the sampled inputs were faster than this. this metric helps identify slower interactions that occurred less frequently during the benchmark.
  • p99 — the 99th percentile of the input latency in the test run. only 1% of sampled inputs were slower than this. this represents the worst-case scenarios encountered during the benchmark, useful for identifying potential performance outliers.
  • blocking time — the total time during which the main thread was blocked, preventing user input and UI updates. this metric helps identify performance bottlenecks that may cause the interface to feel unresponsive.
  • test duration — how long the test run took to complete.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 44.66% 63617 / 142441
🔵 Statements 44.66% 63617 / 142441
🔵 Functions 48.25% 3396 / 7038
🔵 Branches 79.32% 12908 / 16272
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/sanity/src/core/components/inputs/DateInputs/DatePicker.tsx 91.17% 69.23% 100% 91.17% 41-44
packages/sanity/src/core/components/inputs/DateInputs/TimeInput.tsx 100% 100% 100% 100%
packages/sanity/src/core/components/inputs/DateInputs/calendar/Calendar.tsx 87.42% 87.12% 57.14% 87.42% 162, 208-230, 247, 350-354, 414-428, 440-453
Generated in workflow #46096 for commit 76a6997 by the Vitest Coverage Report Action

Copy link
Contributor

@juice49 juice49 left a comment

Choose a reason for hiding this comment

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

This is so good. Especially finally solving the issue that prevents the selected value being persisted on blur. Thanks, Pedro!

I don't predict any issues in switching away from the lazy input myself.

@pedrobonamin pedrobonamin merged commit 84418b4 into main Nov 26, 2025
72 of 76 checks passed
@pedrobonamin pedrobonamin deleted the sapp-3184 branch November 26, 2025 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'datetime' options 'timeStep' not working 'datetime' options timeStep not working

3 participants