Repository navigation
fix(ProgressBar): a determinate fill keeps moving while JavaScript runs - #8196
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsProgressBar (@astryxdesign/core) · View in Storybook
Component Size
Sizes are gzip. Import counts the JavaScript the import loads eagerly; CSS counts the package stylesheet rules referenced by the modules it can load from its own package, lazily loaded ones included. Bundle Size SummaryGzip figures measure each package's entry file, not the code an import pulls in.
Accessibility AuditStatus: The accessibility audit did not run on this pull request. It runs after merges to Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
cf73cba to
125bcb9
Compare
There was a problem hiding this comment.
The new compositor fill fixes the freeze: in Chromium the fill now reaches its new value while a 700 ms script runs, where it used to stall and then jump. Approval waits on an engineering owner deciding two visual effects that no current spec covers: the lens-shaped leading end below about one track height of fill, and the fill sweeping across the track (to about 91% for a 30% bar) when the page or region dir flips at runtime, a question design:bidirectionality OQ4 leaves open. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so if they are an engineering owner. Separately, please fix:
- The fill's RTL mirror keys on any RTL ancestor (
:is([dir="rtl"] *)inProgressBar.tsx), so a bar in an LTR region inside an RTL page draws its fill from the right while its label and marks stay LTR;':dir(rtl)', whichDraweralready uses, follows the nearestdirinstead. - The Chromium RTL test sets
<html dir>while the story's wrapper staysdir="ltr", so it currently asserts that nested case; setting the story's own direction would test a real RTL region.
[Automated review]
| transitionProperty: 'width', | ||
| transform: { | ||
| default: 'translateX(calc(var(--_progress-bar-fill, 0%) - 100%))', | ||
| ':is([dir="rtl"] *)': |
There was a problem hiding this comment.
:is([dir="rtl"] *) matches whenever any ancestor is RTL, so a bar inside <div dir="ltr"> on an RTL page takes this transform. Its fill then grows from the right while its label, value text and marks stay LTR; on a 30% bar, a 20% mark is left on the bare track. design:bidirectionality DR3 requires ordered progression to follow the containing region's direction. ':dir(rtl)' resolves from the nearest dir, as Drawer.tsx already does through StyleX.
| for (const dir of ['ltr', 'rtl'] as const) { | ||
| await open(page, 0); | ||
| await page.evaluate(d => { | ||
| document.documentElement.dir = d; |
There was a problem hiding this comment.
This sets <html dir>, but Storybook's decorator keeps every story inside <div dir={direction}>, which is ltr by default. The bar's region therefore stays LTR here, and the RTL assertion below pins the fill to the right of an LTR region. Setting the story's direction global (or the wrapper's dir) would test a real RTL region, and an LTR-inside-RTL case would cover the nested regression.
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] A determinate ProgressBar keeps moving to its new value while a script runs. The fill animated its `width`, which lays out and repaints on the main thread every frame, so a value change stalled for as long as the page ran JavaScript and then jumped. The fill now spans the track and slides into place with a transform that the browser animates on its compositor, in Chromium and in Safari, laying out and painting nothing per frame. Duration, easing, colors, marks and RTL are unchanged; the track now clips its fill to the rounded rail in both modes, so below about one track height of fill the leading end follows the track's curve. |
There was a problem hiding this comment.
"RTL are unchanged" does not hold for an LTR region inside an RTL page, where the fill is now drawn from the right, or for a runtime dir flip, where the fill now animates across the track. Please correct it once those are settled.
There was a problem hiding this comment.
The compositor fill fixes the freeze: in Chromium the fill now keeps moving to its new value while a 700 ms script runs, where it used to stall and then jump. Approval waits on an engineering owner deciding two visual effects that no current spec covers, the lens-shaped leading end below about one track height of fill and the fill sweeping across the track (to about 91% for a 30% bar) when the page or region dir flips at runtime, which design:bidirectionality OQ4 leaves open; an engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner. Independently of that decision:
ProgressBar.tsx:250keys the fill's mirror on any RTL ancestor (:is([dir="rtl"] *)), so a bar in an LTR region inside an RTL page fills from the right;':dir(rtl)', whichDraweralready uses, follows the nearestdir.- The Chromium RTL test sets
<html dir>while Storybook keeps the story in<div dir="ltr">, so it asserts that nested case; give it a real RTL region and an LTR-inside-RTL case. - The Changeset says RTL is unchanged and names only the new small-value shape; please correct it once the owner has ruled.
- The red
pr-a11yjob comes from a stepmainadded for a lab spec this branch does not have yet, and your new ProgressBar step passes there, so a rebase ontomainclears it.
[Automated review]
There was a problem hiding this comment.
The compositor fill fixes the freeze: in Chromium the fill now keeps moving to its new value while a 700 ms script runs, and the mirror now follows the bar's own direction, so LTR regions inside RTL pages fill from the left. Approval waits on an engineering owner deciding three consequences that no current spec settles: the lens-shaped leading end below about one track height of fill, the fill sweeping across the track when the page or region dir flips at runtime (design:bidirectionality OQ4 leaves this open), and new values landing at once on every pointer under reduced motion, where design:reduced-motion DR2 asks a coarse pointer to cross-fade if determinate progress is in its scope. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner. Independently of that decision:
- The Changeset should name the old small-value shape (a narrow full-height capsule) beside the new one and mention the animated direction flip, as
spec:AST-017FR3 asks. - The size report needs the base and head gzip size of the
@astryxdesign/corepackage stylesheet, whichspec:AST-080FR8 requires beside the component figures.
[Automated review]
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] A determinate ProgressBar keeps moving to its new value while a script runs. The fill animated its `width`, which lays out and repaints on the main thread every frame, so a value change stalled for as long as the page ran JavaScript and then jumped. The fill now spans the track and slides into place with a transform that the browser animates on its compositor, in Chromium and in Safari, laying out and painting nothing per frame. Under reduced motion a new value now lands at once, on every pointer. Otherwise duration, easing, colors, marks and right-to-left drawing are unchanged (the fill mirrors with the bar's own direction, so a bar in a left-to-right region of a right-to-left page still fills from the left); the track now clips its fill to the rounded rail in both modes, so below about one track height of fill the leading end follows the track's curve. |
There was a problem hiding this comment.
This names the new small-value end ("follows the track's curve") but not the old one, a narrow full-height capsule, and says right-to-left drawing is unchanged without mentioning that a runtime dir flip now sweeps the fill across the track. spec:AST-017 FR3 asks a visual change's Changeset to name the old and new appearance; once an engineering owner rules on the shape, FR3 also decides between [fix] and [feat].
There was a problem hiding this comment.
The compositor fill fixes the freeze: in Chromium the fill now keeps moving to its new value while a 700 ms script runs, where it used to stall and then jump. Approval waits on an engineering owner deciding three consequences that no current spec settles: the lens-shaped leading end below about one track height of fill, the fill sweeping across the track when the page or region dir flips at runtime (design:bidirectionality OQ4 leaves this open), and new values landing at once on every pointer under reduced motion, where design:reduced-motion DR2 asks a coarse pointer to cross-fade if determinate progress is in its scope. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner. Independently of that decision, the size report needs this head's figures: astryx.css is now 34,300 B gzip (+90 B), not the reported 34,254 B (+44 B), because the last commit's two reduced-motion keys add 46 B, so please update it and ProgressBar's CSS delta, or return to the single (prefers-reduced-motion: reduce) key, which behaves the same.
[Automated review]
| // The keys are the shared reduced-motion queries, a fine pointer's and a | ||
| // coarse pointer's, spelled as the record's other transitions spell them. | ||
| transitionDuration: { | ||
| default: durationVars['--duration-medium'], | ||
| '@media (prefers-reduced-motion: reduce) and (not (pointer: coarse))': | ||
| '0s', | ||
| '@media (prefers-reduced-motion: reduce) and (pointer: coarse)': '0s', | ||
| }, |
There was a problem hiding this comment.
These two keys together match every pointer, exactly like the single (prefers-reduced-motion: reduce) key they replace, so behaviour is unchanged (Chromium applies 0s with a mouse and with a finger). StyleX makes the first key exclusive of the second, so the package stylesheet carries @media ((prefers-reduced-motion: reduce) and (not (pointer: coarse)) and (not (prefers-reduced-motion: reduce))) or ((prefers-reduced-motion: reduce) and (not (pointer: coarse)) and (not (pointer: coarse))), and astryx.css grows from 34,254 B to 34,300 B gzip; the size line in the description still shows 34,254 B, and spec:AST-080 FR8 needs this head's figure. No other module spells either query yet, so the comment's "spelled as the record's other transitions spell them" describes a convention the repository does not have; the single key would keep both the CSS and the comment simpler.
There was a problem hiding this comment.
The compositor fill fixes the freeze: in Chromium the fill now keeps moving to its new value while a 700 ms script runs, where it used to stall and then jump. Approval waits on an engineering owner deciding three consequences that no current spec settles: the lens-shaped leading end below about one track height of fill, the fill sweeping across the track when the bar's direction flips at runtime (design:bidirectionality OQ4 leaves this open), and new values landing at once on every pointer under reduced motion, where design:reduced-motion DR2 asks a coarse pointer to cross-fade if determinate progress is in its scope. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner. Independently of that decision, please keep the fill's forced-colors boundary whole: the track's new clip cuts its start cap on every partly filled bar (only a ) arc is left at 2%), which architecture:theme-tokens INV11 rules out, and giving the fill its old width geometry under forced-colors: active closes it.
[Automated review]
| // The indeterminate fill overshoots the track on both sides and must be | ||
| // clipped to the visible rail. Marks are suppressed in this mode. | ||
| trackClipped: { | ||
| overflow: 'hidden', |
There was a problem hiding this comment.
With the fill spanning the track and translated back, this clip also cuts the fill's forced-colors CanvasText outline (lines 250-258): in forced colors every bar filled between 0% and 100% loses the outline's start cap, and at 2% only the leading ) arc is left, where main draws a closed capsule. architecture:theme-tokens INV11 asks a status fill to keep a visible CanvasText border "so its shape survives". Giving the fill its old geometry under @media (forced-colors: active) (width: var(--_progress-bar-fill, 0%), transform: none, transition on width) closes it; the jsdom forced-colors check passes either way, so a Chromium assertion on the rendered boundary would hold it.
There was a problem hiding this comment.
Fixed in de43cd2. Under forced-colors: active the fill is sized to the value again (width: var(--_progress-bar-fill, 0%), transform: none, a width transition), so its CanvasText outline is a closed capsule inside the track; elsewhere it still moves on the compositor. A Chromium test emulates forced colors and checks, at 2% and 50% in LTR and RTL, that the fill sits inside the track at the value and that the outline's color is drawn at the track's inline-start edge. It fails against the slid fill, whose box started 362.6 px before the track.
|
Approval here waits on an engineering owner's decision on three consequences of moving the fill by transform, which no current record settles:
Should the record take these as they are, or ask for a change to any of them? |
Under forced colors the determinate fill is sized to the value again, so the track's clip never cuts its CanvasText outline. With a finger it keeps this PR's touch minimum (two track heights above zero) and its flip offset in that width; the touch transform's key sits before the forced-colors key, so StyleX negates it there. A Chromium test emulates forced colors under a finger and checks the sized fill at 1% and 50% in LTR and RTL. The unit test reads the touch transform from the source: under the negated condition the jsdom runtime injects only part of it. The reduced-motion comment says only what holds.
There was a problem hiding this comment.
The compositor fill fixes the freeze: in Chromium the fill now keeps moving to its new value while a 700 ms script runs, and in forced colors its outline is a closed capsule again. Approval waits on an engineering owner deciding three consequences that no current spec settles: the lens-shaped leading end below about one track height of fill, the fill sweeping across the track when the bar's direction flips at runtime (design:bidirectionality OQ4 leaves this open), and new values landing at once on every pointer under reduced motion, where design:reduced-motion DR2 asks a coarse pointer to cross-fade if determinate progress is in its scope. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner. Nothing else needs to change before then.
[Automated review]
|
Posted by Cindy's agent on her behalf. Thanks for moving the fill onto a compositor animation. Cindy's decision: keep this transform animation for the determinate fill, with the fill clipped to the rounded track, so its ends stay round at every value and a small value never shows a flattened sliver. This PR already does that, and under Reduce Motion a new value lands at once on every pointer, matching her separate Reduce Motion decision. No changes needed for the decision. |
|
/approve-spec de43cd2 |
|
/approve-spec de43cd2 |
A determinate fill's value change ran as a width transition, which the browser lays out and repaints on the main thread every frame, so it stopped while a script ran and then jumped to the new value. The fill now spans the whole track, clipped to the rounded rail, and slides along it by transform, so the change runs on the compositor, timed by the theme's duration and easing as before. Under forced colors it is still sized by its width.
de43cd2 to
f55c39b
Compare
There was a problem hiding this comment.
This looks ready to approve: the ProgressBar fill now keeps moving to its new value while the page runs JavaScript, a new value lands at once under reduced motion as design:reduced-motion asks, forced colors keep a closed outline, and the small-value end and animated direction flip match the engineering owner's recorded decision. The new Chromium spec passes on this head and fails against the base, so it guards the fix. CI has not run on this head because the pull request is still a draft; mark it ready for review so the required checks run before merging.
[Automated review]
User impact
Part of making Astryx match iOS, whose progress indicators keep moving while busy. Progress usually arrives while the page is busy, and the fill then freezes and jumps (Chromium, Safari), so the work looks stuck. Now it keeps sliding.
Problem and solution fit
The fill animated
width, laid out and painted on the main thread every frame, so a busy page stalls it.Options:
width: the freeze stays.scaleXon a full-length fill: compositor, but it stretches the round ends.translateXof a full-length fill in a clipping track: compositor, round ends. Costs: a tiny fill's end follows the track's curve; a runtime direction flip sweeps the fill across.This PR takes the third; cixzhang decided to keep it.
Expected behavior and authority
component:ProgressBar's targets are unchanged; #6248 moved the marks out of the track, so it can clip. Under Reduce Motion a new value lands at once (design:reduced-motionDEC-3).Smallest restoration
ProgressBar.tsx: the fill transitionstransforminstead ofwidth, on the theme's duration and easing; the track clips; the fill mirrors by its own direction. Forced colors keep the width geometry, so the outline stays whole (architecture:theme-tokensINV11). No API change.Evidence
Scope
Testing
What I ran and what it showed:
__STORYBOOK_ADDONS_CHANNEL__.emit('updateStoryArgs', {storyId: 'core-progressbar--default', updatedArgs: {value: 90}}); setTimeout(() => { const end = performance.now() + 700; while (performance.now() < end); }, 30);mainfreezes, then jumps; this PR keeps sliding, with no per-frame layout or paint. iOS simulator: the same (above).main.pnpm test:uipass, apart from failures known elsewhere: the rich-text race test(richtext): the code block header tests wait for the copy button's tooltip #8569 fixes, and test(storybook): run the story-tree check where Storybook is built, and bring the tree back to its shape #8509 and fix(cli): a crashed run's release install is recognized by the Node it ran on, whatever its name #8520 in the node project.