Repository navigation
fix(carousel): time autoplay with a per-panel animation and pause it on hover - #3347
Merged
Merged
Conversation
…on hover The autoplay browser tests failed intermittently in CI, each time one panel ahead of the expected sequence. Autoplay ran on a free-running setInterval that started inside render()'s act(), while the tests sampled on their own clock started after render() returned, with half an interval of slack. Forced layout and CI load pushed the two clocks a tick apart. Autoplay now times each panel with a keyframe-less Web Animations animation on the stage, started by an effect after each committed panel, so a step never acts on a panel that hasn't rendered. The animation runs on the document timeline, so it pauses in a hidden tab, and it pauses while the pointer is over the carousel (WCAG 2.2.2), resuming with the remaining time. Without the Web Animations API (jsdom) a setTimeout per panel is used instead. The browser tests step autoplay with Animation.finish() and wait for the next dwell, so no wall clock is involved. New tests cover the hover pause.
…already-present pointer The document timeline keeps running in a hidden tab, so the dwell finished as soon as the tab was shown again instead of resuming with the time it had left. Pause it on visibilitychange. A carousel that mounts under the pointer gets no pointerenter, so pointermove now also marks the pointer as over it. The browser test picks the dwell by its duration rather than taking the stage's first animation.
Niznikr
approved these changes
Nov 20, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes the flaky
components/carousel/__tests__/carousel.browser.test.jsxautoplay tests, which have failed intermittently across the 11.0.0-rc.1 stack and on master (runs 44588632552, 44421155026, 44417854821, 44205040933, 44184736972, 44002779596, 42139457771).Additional description
Root cause. Autoplay ran on a free-running
setIntervalthat started insiderender()'sact(). The tests sampled on their own clock, started afterrender()returned, with half an interval (±50ms) of slack. Forced layout (offsetWidth, heavier with the SLDS 2 CSS) and CI load pushed the two clocks a tick apart, so each failure is a correct panel sequence shifted by one tick (for example[0, -624, -936, 0, -312]for[0, -312, -624, -936, 0]). The component's panel order was always right; the test raced it.Fix. Autoplay now times each panel with a keyframe-less Web Animations animation on the stage, started by an effect after each committed panel:
visibilitychangelistener does the pausing there.pointermovealso counts as hovering, which covers a carousel that mounts under the pointer and never getspointerenter.setTimeoutper panel.The browser tests step autoplay with
Animation.finish()and wait for the next dwell, so no wall clock is involved. New tests cover the hover pause, a pointer already over the carousel, and the hidden-tab pause. The test picks the dwell by its duration, not by taking the stage's first animation.Behavior change: autoplay pauses while hovered or while the tab is hidden. Previously it kept advancing under the pointer, and on return to a background tab it advanced straight away.
Verification
render(): the new tests pass, and the old tests on master fail 5/13 the same way CI does.visibilitychangelistener or thepointermovehandler each fails its new test.npm run test:ciis green on this branch, and on the restacked rc.1 stack.This sits at the base of the 11.0.0-rc.1 stack, under #3345, so every PR in the milestone picks it up.
CONTRIBUTOR checklist (do not remove)
Please complete for every pull request.
Green gate — all of these must pass locally (CI runs the same):
npm run lintpasses with 0 errors and 0 warnings (npm run lint:fixto auto-fix). No new warnings: the carousel has the same 5 as master.npm run typecheckis clean (tsc --noEmit).npm test -- --runpasses — this runs both Vitest projects (jsdomunit+ real-browserbrowser) and the story HTML snapshots. If you changed rendered markup on purpose, update snapshots withnpm test -- --run -uand review the diff.npm run buildsucceeds (type-check + Vite library build +.d.ts+ entry shims).Behavior & docs:
components/button/__tests__). New props and bug fixes should get a regression test. Tests that genuinely need a real browser (focus traversal, layout/measurement, canvas) go in a*.browser.test.jsxfile (thebrowserproject); everything else is jsdom.npm run storybook→ http://localhost:6007/. Confirm the story actually renders and behaves (deprecated Storyshots/Karma are gone; there is no separate browser-tests server). Not yet checked by hand: Carousel › With Autoplay, hover pause.content/visualPickerFigure, render props likerenderItem,iconprops,events), not assumptions — a common source of "component looks broken" reports has been stories authored against the wrong API. Cross-check againstcomponents/<name>/__examples__. No story changes..d.ts(they're generated by the build); JS consumers rely on them via editor type-acquisition. Only the JSDoc onautoplayIntervalandhasAutoplaychanged.REVIEWER checklist (do not remove)
CIworkflow: lint, typecheck, test, build). Chromatic visual review, if configured, has been checked.components/__tests__/__snapshots__/story-snapshots.test.jsx.snap).@salesforce/design-system-react/components/<name>and nested paths resolve for ESM, CJS, and types). Removing/renaming a public component or export is a breaking change →feat!:/BREAKING CHANGE:and a major version bump.