Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue with the US formatting used by formatRelative when no locale defined #7798

Merged
merged 4 commits into from
Nov 13, 2024

Conversation

jordanl17
Copy link
Member

@jordanl17 jordanl17 commented Nov 12, 2024

Description

Currently:
For dates more than a week in the past/future, these would be formatted as 'MM/dd/yyyy':
Screenshot 2024-11-12 at 13 19 53

Now:
These dates are formatted correctly according to the locale formatting of the client, eg in my case 'dd/MM/yyyy':
Screenshot 2024-11-12 at 13 26 06

Ideally we would pass through the client locale to date-fns however given the way that date-fns requires the locale to be imported, and that the mappings of navigator.language to the date-fns are rather specific, taking the approach in this PR felt most extensible to all locales.

What to review

Testing

Added tests for the wrapper util formatRelativeLocale

Notes for release

N/A

N/A

Copy link

vercel bot commented Nov 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 12, 2024 2:43pm
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 12, 2024 2:43pm
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 12, 2024 2:43pm
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 12, 2024 2:43pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 12, 2024 2:43pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Nov 12, 2024 2:43pm

{!isPublishedPerspective(release) && isReleaseScheduledOrScheduling(release) && (
<Box padding={2}>
<Text size={1}>
<LockIcon />
Copy link
Member Author

Choose a reason for hiding this comment

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

Lock now shows for scheduled releases

@@ -169,10 +174,10 @@ export const GlobalPerspectiveMenuItem = forwardRef<
{displayTitle}
</Text>
{!isPublishedPerspective(release) &&
release.metadata.releaseType !== 'undecided' &&
release.metadata.releaseType === 'scheduled' &&
Copy link
Member Author

Choose a reason for hiding this comment

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

Improvement to handle case that intendedPublishAt has not been updated when release type is (which shouldn't happen in studio, but could if CLI/API is used directly)

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Nov 12, 2024

Component Testing Report Updated Nov 12, 2024 2:38 PM (UTC)

❌ Failed Tests (1) -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 1m 16s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 14s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 43s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 53s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 29s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 16s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 2m 34s 1 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 1m 14s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 2m 44s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ❌ Failed (Inspect) 1m 59s 17 0 1
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 14s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 43s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 29s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 58s 12 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 0s 0 3 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 0s 0 3 0

Copy link
Contributor

github-actions bot commented Nov 12, 2024

⚡️ Editor Performance Report

Updated Tue, 12 Nov 2024 14:41:00 GMT

Benchmark reference
latency of sanity@latest
experiment
latency of this branch
Δ (%)
latency difference
article (title) 17.9 efps (56ms) 13.1 efps (77ms) +21ms (+36.6%) 🔴
article (body) 59.9 efps (17ms) 59.5 efps (17ms) +0ms (+0.6%)
article (string inside object) 18.9 efps (53ms) 13.3 efps (75ms) +22ms (+41.5%) 🔴
article (string inside array) 16.4 efps (61ms) 11.0 efps (91ms) +30ms (+49.2%) 🔴
recipe (name) 27.0 efps (37ms) 18.7 efps (54ms) +17ms (+44.6%) 🔴
recipe (description) 31.3 efps (32ms) 19.6 efps (51ms) +19ms (+59.4%) 🔴
recipe (instructions) 99.9+ efps (7ms) 99.9+ efps (9ms) +2ms (-/-%)
synthetic (title) 14.6 efps (69ms) 5.7 efps (174ms) +106ms (+154.0%) 🔴
synthetic (string inside object) 15.4 efps (65ms) 6.0 efps (168ms) +103ms (+158.5%) 🔴

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) 56ms 60ms 73ms 232ms 372ms 13.4s
article (body) 17ms 20ms 32ms 178ms 308ms 6.1s
article (string inside object) 53ms 55ms 60ms 214ms 238ms 8.1s
article (string inside array) 61ms 65ms 76ms 212ms 683ms 8.9s
recipe (name) 37ms 40ms 46ms 75ms 0ms 9.1s
recipe (description) 32ms 36ms 40ms 90ms 23ms 6.2s
recipe (instructions) 7ms 8ms 10ms 53ms 6ms 3.6s
synthetic (title) 69ms 76ms 84ms 304ms 1591ms 15.6s
synthetic (string inside object) 65ms 68ms 74ms 312ms 1285ms 9.7s

🧪 Experiment result

The performance result of this branch

Benchmark latency p75 p90 p99 blocking time test duration
article (title) 77ms 82ms 101ms 282ms 2682ms 15.8s
article (body) 17ms 26ms 51ms 241ms 613ms 6.6s
article (string inside object) 75ms 77ms 81ms 203ms 2492ms 11.0s
article (string inside array) 91ms 97ms 141ms 301ms 3379ms 12.7s
recipe (name) 54ms 57ms 61ms 129ms 1166ms 11.6s
recipe (description) 51ms 57ms 70ms 114ms 972ms 8.6s
recipe (instructions) 9ms 11ms 15ms 77ms 96ms 3.9s
synthetic (title) 174ms 192ms 355ms 972ms 11440ms 33.3s
synthetic (string inside object) 168ms 177ms 263ms 994ms 9415ms 20.4s

📚 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.

@jordanl17 jordanl17 marked this pull request as ready for review November 12, 2024 15:16
@jordanl17 jordanl17 requested a review from a team as a code owner November 12, 2024 15:16
@jordanl17 jordanl17 requested review from RitaDias and removed request for a team November 12, 2024 15:16
Copy link
Contributor

@RitaDias RitaDias left a comment

Choose a reason for hiding this comment

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

Thanks for this Jordan, this is great :)

@jordanl17 jordanl17 merged commit 65673fa into corel Nov 13, 2024
62 checks passed
@jordanl17 jordanl17 deleted the corel-253-date-formatting-locale branch November 13, 2024 11:44
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.

2 participants