Skip to content

fix(ui): Pricing table layout shift on switch changes#8742

Merged
alexcarpenter merged 3 commits into
mainfrom
alexcarpenter/bill-1705-billing-plans-page-layout-breaks-after-repeated-annual
Jun 4, 2026
Merged

fix(ui): Pricing table layout shift on switch changes#8742
alexcarpenter merged 3 commits into
mainfrom
alexcarpenter/bill-1705-billing-plans-page-layout-breaks-after-repeated-annual

Conversation

@alexcarpenter
Copy link
Copy Markdown
Member

@alexcarpenter alexcarpenter commented Jun 3, 2026

Description

Fix Chrome-specific scroll jump when toggling the billing period switch on the pricing table.

BEFORE

before.mov

AFTER

after.mov

Fixes BILL-1705

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 3, 2026

🦋 Changeset detected

Latest commit: 1c07698

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@clerk/ui Patch
@clerk/chrome-extension Patch

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

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jun 3, 2026 10:17pm

Request Review

@github-actions github-actions Bot added the ui label Jun 3, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 8b358dd9-684b-46f0-8cca-8ac717a6becc

📥 Commits

Reviewing files that changed from the base of the PR and between 312c449 and 1c07698.

📒 Files selected for processing (1)
  • .changeset/fix-switch-scroll-jump.md
💤 Files with no reviewable changes (1)
  • .changeset/fix-switch-scroll-jump.md

📝 Walkthrough

Walkthrough

This PR fixes a Chrome-specific scroll-jump when toggling the pricing table billing-period switch. The Switch component's root now sets position: 'relative' to provide a positioning context for absolutely-positioned internals. The visually-hidden now includes inset: 0 to constrain its bounding box. A changeset documents a patch release for @clerk/ui describing the fix.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main bug fix: a layout shift issue on the pricing table when the switch is toggled, which directly matches the changeset's purpose.
Description check ✅ Passed The description is directly related to the changeset, explaining the Chrome-specific scroll jump issue with before/after assets and referencing the relevant ticket (BILL-1705).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 3, 2026

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8742

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8742

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8742

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8742

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8742

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8742

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8742

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8742

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8742

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8742

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8742

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8742

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8742

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8742

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8742

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8742

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8742

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8742

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8742

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8742

commit: 1c07698

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 3, 2026

Break Check: no API changes detected across the tracked packages.

Last ran on 1c07698. Pushes that change no tracked declarations (no API surface change vs. base) are skipped and don't update this comment.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/ui/src/elements/Switch.tsx (1)

1-136: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add tests to cover the positioning changes.

No tests have been added or modified to verify the fix. While browser-specific layout issues can be challenging to test, adding interaction tests for the Switch component would provide valuable regression protection. As per coding guidelines, changes should include test coverage.

Consider adding tests that:

  • Verify the Switch toggles correctly when clicked
  • Verify the controlled and uncontrolled patterns work as expected
  • Verify accessibility properties (role, ARIA attributes) are correctly applied
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ui/src/elements/Switch.tsx` around lines 1 - 136, Add
unit/interaction tests for the Switch component to cover toggling behavior,
controlled vs uncontrolled modes, and accessibility attributes: write tests that
render the Switch, simulate a click and assert the visible state change (thumb
position via data-checked or DOM changes) and that onChange is called; render
with controlled prop isChecked and assert clicking calls onChange but does not
change visual state unless prop updates; render with defaultChecked and assert
internal state toggles on click; and assert role="switch",
aria-label/aria-labelledby props, and disabled behavior (no state change or
onChange when isDisabled=true). Target the exported Switch component and its
public props (isChecked, defaultChecked, onChange, isDisabled,
'aria-label'/'aria-labelledby') in your test files.
🧹 Nitpick comments (1)
packages/ui/src/elements/Switch.tsx (1)

77-77: 💤 Low value

Consider adding a clarifying comment for the inset: 0 addition.

The inset: 0 works correctly to constrain the hidden input's bounding box and fix the Chrome scroll-jump behavior. However, the interaction between inset: 0 and the explicit width: '1px' and height: '1px' from visuallyHidden() might be non-obvious to future maintainers.

📝 Suggested clarifying comment
         style={{
           ...common.visuallyHidden(),
+          // inset: 0 constrains the bounding box to prevent Chrome scroll jump during toggle
           inset: 0,
         }}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ui/src/elements/Switch.tsx` at line 77, Add a short clarifying
comment next to the style entry that sets "inset: 0" (the hidden input styling
in Switch.tsx) explaining that inset: 0 is required to constrain the hidden
input's bounding box and prevents Chrome's scroll-jump behavior, and note that
this works together with the explicit width/height from visuallyHidden() (width:
'1px', height: '1px') rather than replacing them; reference the hidden input and
visuallyHidden() so future maintainers understand the intent and interplay.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/ui/src/elements/Switch.tsx`:
- Around line 1-136: Add unit/interaction tests for the Switch component to
cover toggling behavior, controlled vs uncontrolled modes, and accessibility
attributes: write tests that render the Switch, simulate a click and assert the
visible state change (thumb position via data-checked or DOM changes) and that
onChange is called; render with controlled prop isChecked and assert clicking
calls onChange but does not change visual state unless prop updates; render with
defaultChecked and assert internal state toggles on click; and assert
role="switch", aria-label/aria-labelledby props, and disabled behavior (no state
change or onChange when isDisabled=true). Target the exported Switch component
and its public props (isChecked, defaultChecked, onChange, isDisabled,
'aria-label'/'aria-labelledby') in your test files.

---

Nitpick comments:
In `@packages/ui/src/elements/Switch.tsx`:
- Line 77: Add a short clarifying comment next to the style entry that sets
"inset: 0" (the hidden input styling in Switch.tsx) explaining that inset: 0 is
required to constrain the hidden input's bounding box and prevents Chrome's
scroll-jump behavior, and note that this works together with the explicit
width/height from visuallyHidden() (width: '1px', height: '1px') rather than
replacing them; reference the hidden input and visuallyHidden() so future
maintainers understand the intent and interplay.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: b0b92426-e995-43e8-b7aa-cad45d0dad13

📥 Commits

Reviewing files that changed from the base of the PR and between 03e2bba and 312c449.

📒 Files selected for processing (2)
  • .changeset/fix-switch-scroll-jump.md
  • packages/ui/src/elements/Switch.tsx

Copy link
Copy Markdown
Member

@wobsoriano wobsoriano 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 the screen record demos 👍🏼

Copy link
Copy Markdown
Member

@dstaley dstaley left a comment

Choose a reason for hiding this comment

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

approved, but remove the clerk-js entry from the changeset

Comment thread .changeset/fix-switch-scroll-jump.md Outdated
Co-authored-by: Dylan Staley <88163+dstaley@users.noreply.github.com>
@alexcarpenter alexcarpenter merged commit 0aa6e81 into main Jun 4, 2026
45 checks passed
@alexcarpenter alexcarpenter deleted the alexcarpenter/bill-1705-billing-plans-page-layout-breaks-after-repeated-annual branch June 4, 2026 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants