Add experimental React RelativeTime - #8250
Conversation
|
🦋 Changeset detectedLatest commit: 5b7d457 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
Integration test results from github/github-ui PR: |
|
|
||
| const RelativeTimeComponent = createComponent(RelativeTimeElement, 'relative-time') | ||
|
|
||
| const localeOptions: Intl.DateTimeFormatOptions = {month: 'short', day: 'numeric', year: 'numeric'} |
There was a problem hiding this comment.
I think we need a fallback timezone for this, otherwise we'll have unsafe hydration when the server formats in UTC but the client render formats in locale timezone?
we probably need a path to making this configurable for the server pass too
There was a problem hiding this comment.
Are we already hitting that hydration mismatch today?
There was a problem hiding this comment.
Yep - we are. I updated the custom-element version with a fallback to a fixed UTC renderer - but that's not ideal
we should be able to avoid that a bit - since we don't need to wait for custom element hydration to show the updated value, but we do hit tz hydration mismatches today, as well as value replacement (light -> shadow swaps) causing shifts
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bfa22b31-cbe2-4b07-8add-f302af4c1a2b
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bfa22b31-cbe2-4b07-8add-f302af4c1a2b
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bfa22b31-cbe2-4b07-8add-f302af4c1a2b
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bfa22b31-cbe2-4b07-8add-f302af4c1a2b
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bfa22b31-cbe2-4b07-8add-f302af4c1a2b
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: bfa22b31-cbe2-4b07-8add-f302af4c1a2b
f3d833d to
5b7d457
Compare
Closes #
Changelog
New
ExperimentalRelativeTimeis available from@primer/react/experimentalfor opt-in evaluation of the native React implementation.primer_react_relative_timeto evaluate the implementation through the establishedRelativeTimeentry point.Changed
RelativeTimecomponent continues to render the existing<relative-time>custom element and retains its dependency, props, callback event contract, refs, and serialized formatting attributes by default.<time>, and uses Intl APIs for formatting and live updates. It preserves itsdata-componentanddatetimecontract; it intentionally does not reproduce legacy formatting attributes. If rollout diagnostics need DOM metadata, add a dedicateddata-relative-time-*contract rather than reviving custom-element attributes.Removed
Rollout strategy
Testing & Reviewing
ff7297694showed 297 DataTable failures across 99 snapshots (three retries each). The stable default had reverted to<relative-time>, while the prior mask only targeted the experimental<time>shape. Commitfba412b2emasks both shapes; no baselines were regenerated.