You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Adding the ability to add a displayTimezone option to the datetime input. This allows you to specify the timezone in which the stored UTC string from content lake will be displayed. When enabled, a tooltip is shown at the bottom left of the input field which indicates the timezone the field is representing. When you start editing this disappears.
A common use case here could be anything local that you would be working on in another timezone, for example concert times, apartment viewing times etc. etc. which are hard to work with today as the studio (just like the Date API) respects only the browsers relative display of the UTC string.
We have lots of signal on this one in this thread, as well as directly from users.
In addition to this, I decided to give it a go of removing moment from the @sanity/util package as a testbed how we should go about removing it across the entire codebase.
I am using the new date-fns/tz and date-fns/utc packages from date-fns. The reason for these is that they are very lightweight, TZDateMini which I am using here is only 916 B, which is a whopper difference from the locale bloat from moment-timezone dep we would need to make this work with moment.
As we have the ability to add custom date formats via the options on the datetime input and this is documented as support moment.js formats, I decided to write a formatter that would use the Intl.DateTimeFormat.format functionality instead by mapping the moment formatting to that format object.
What to review
The naming of displayTimezone is worth a discussion.
The UI that I have chosen, with the text below should also be taken into consideration as to whether that is the best approach.
Browser support, not baking locales and timezones into the package and instead relying on the Intl.DateTimeFormat browser API means that browser versions outside the widely supported will not work.
Testing
I added two tests where I thought they should go that take account for this being in place and for Winter and Summer timezones. Happy to add more should we sit fit!
Notes for release
Might actually be worth mentioning: "The ability to specify the display timezone for your datetime fields".
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)
42ms
46ms
68ms
422ms
754ms
11.0s
article (body)
22ms
28ms
44ms
119ms
358ms
6.3s
article (string inside object)
41ms
42ms
44ms
60ms
167ms
6.9s
article (string inside array)
48ms
49ms
57ms
268ms
453ms
7.8s
recipe (name)
19ms
22ms
25ms
44ms
0ms
7.6s
recipe (description)
20ms
21ms
25ms
40ms
0ms
4.8s
recipe (instructions)
7ms
9ms
11ms
12ms
0ms
3.3s
synthetic (title)
53ms
58ms
63ms
146ms
702ms
12.6s
synthetic (string inside object)
52ms
55ms
65ms
513ms
1157ms
8.4s
🧪 Experiment result
The performance result of this branch
Benchmark
latency
p75
p90
p99
blocking time
test duration
article (title)
45ms
66ms
79ms
492ms
853ms
11.6s
article (body)
23ms
25ms
28ms
94ms
111ms
6.0s
article (string inside object)
39ms
42ms
45ms
212ms
249ms
6.8s
article (string inside array)
46ms
48ms
52ms
162ms
207ms
7.2s
recipe (name)
21ms
24ms
25ms
42ms
0ms
7.5s
recipe (description)
20ms
22ms
23ms
38ms
3ms
4.9s
recipe (instructions)
7ms
9ms
11ms
33ms
0ms
3.3s
synthetic (title)
51ms
54ms
58ms
245ms
666ms
12.8s
synthetic (string inside object)
51ms
54ms
65ms
551ms
1127ms
8.6s
📚 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.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adding the ability to add a
displayTimezone
option to thedatetime
input. This allows you to specify the timezone in which the stored UTC string from content lake will be displayed. When enabled, a tooltip is shown at the bottom left of the input field which indicates the timezone the field is representing. When you start editing this disappears.A common use case here could be anything local that you would be working on in another timezone, for example concert times, apartment viewing times etc. etc. which are hard to work with today as the studio (just like the Date API) respects only the browsers relative display of the UTC string.
We have lots of signal on this one in this thread, as well as directly from users.
In addition to this, I decided to give it a go of removing moment from the
@sanity/util
package as a testbed how we should go about removing it across the entire codebase.I am using the new date-fns/tz and date-fns/utc packages from date-fns. The reason for these is that they are very lightweight,
TZDateMini
which I am using here is only 916 B, which is a whopper difference from the locale bloat frommoment-timezone
dep we would need to make this work withmoment
.As we have the ability to add custom date formats via the options on the
datetime
input and this is documented as support moment.js formats, I decided to write a formatter that would use the Intl.DateTimeFormat.format functionality instead by mapping the moment formatting to that format object.What to review
displayTimezone
is worth a discussion.Intl.DateTimeFormat
browser API means that browser versions outside the widely supported will not work.Testing
I added two tests where I thought they should go that take account for this being in place and for Winter and Summer timezones. Happy to add more should we sit fit!
Notes for release
Might actually be worth mentioning: "The ability to specify the display timezone for your
datetime
fields".