Skip to content

fix(studio): keep the phone icon size for Buttons inside asChild triggers - #2368

Merged
peppescg merged 2 commits into
mainfrom
fix/studio-trigger-button-icon-size
Oct 16, 2026
Merged

peppescg merged 2 commits into
mainfrom
fix/studio-trigger-button-icon-size

Conversation

@peppescg

Copy link
Copy Markdown
Contributor

Summary

On phones, Studio draws every Button icon at 20px through a rule in apps/web/src/styles.css keyed on [data-slot="button"]. A Button inside a Radix trigger with asChild (TooltipTrigger, DropdownMenuTrigger, and the Popover, Dialog, AlertDialog, Sheet and Collapsible triggers) loses that data-slot, so the rule missed its icon. A bare icon then drew at 18px on phones (Tailwind size-4 is 1rem, and the phone root font size is 18px). #2357 worked around this for one icon with size-4. This PR fixes the root cause once.

Why the Button loses its data-slot

Radix Slot merges the trigger's props onto its child element, and the child's own props win. The <Button> element has no data-slot prop of its own, because Button sets data-slot="button" inside its render. So the trigger's data-slot="tooltip-trigger" arrives in Button's props, and Button spreads {...props} after its own data-slot, which replaces it.

The fix, and why this one

Button now also renders data-button after the props spread, so no merged prop can replace it. The phone rule keys on [data-button] instead of [data-slot="button"].

  • data-slot keeps its meaning. It still names the outermost part, as the trigger tests expect (tooltip-trigger, dropdown-menu-trigger). Moving Button's data-slot after the spread would have broken that.
  • The CSS stays exact. Matching trigger slots in CSS (for example [data-slot"-trigger"]) would also catch Select, Tabs and Accordion triggers, which are not Buttons, and would need a new entry for every new trigger primitive.
  • It covers every trigger at once, including nested triggers such as a TooltipTrigger around a DropdownMenuTrigger, and Button asChild around a link.

What changed

  • components/ui/button.tsx: renders data-button after the props spread.
  • styles.css: the phone glyph rule keys on [data-button] svg.lucide.
  • learning-settings-page.tsx: removes the size-4 workaround from refactor(studio): move the learning refresh tooltip to the Tooltip primitive #2357 on the refresh icon.
  • learning-settings-page.pinning.test.tsx: the review nit. The pin no longer copies the phone selector as a string literal. It reads the selector list of the 20px rule from styles.css, so a change to the rule changes the pin too. The browser journey below measures the drawn size.

Other per-site size-4 icons

Visible change

On phones, the bare icon of a Button inside an asChild trigger grows from 18px to 20px, matching every other Button icon. Examples: the chat header's options, and the schedule detail and list actions. Desktop is unchanged (16px). The learning refresh icon is unchanged at both widths: it held 20px only through its workaround, and now holds it through the shared rule.

No regression

  • Pins first (test(studio): pin …): e2e/trigger-button-icons.spec.ts measures the drawn glyph at 1280px and 390px for a Button inside a TooltipTrigger (learning refresh) and a DropdownMenuTrigger (schedule actions, chat options). On main it passes with the then-current sizes: 16px on desktop for all three; on phones, 20px for refresh and 18px for the two bare icons.
  • The fix commit changes only the phone expectation of the two bare icons, from 18px to 20px. That is the intended change. The fonts.test.ts assertion follows the renamed selector.
  • New button.test.tsx: data-button is present on a plain Button, inside TooltipTrigger asChild and DropdownMenuTrigger asChild (where data-slot names the trigger), and on Button asChild.
  • Mutation proof:
    • With the Button and CSS change reverted and the workaround still removed, all three phone journeys fail (18 != 20), and so do the learning pin, the fonts test and the Button tests.
    • Reverting only the CSS fails the three phone journeys.
    • Removing only data-button from Button fails the three phone journeys.
    • All pass again once restored.
  • Gates (through the shared lock):
    • task studio:check: web 189 files / 1619 tests passed, server 27 files / 252 tests passed. Base: 188 / 1616 web, adding button.test.tsx (3 tests).
    • task studio:browser: 142 passed, 38 skipped. Base: 136 passed, adding the 6 new journeys.
  • Screenshots: each tree was captured twice. The only noise was 33px in one desktop dark learning capture, and Before matched the second After capture there.

Screenshots

Before is 8cc7c23 (main), After is this PR. Red boxes mark changed pixels. There is no Prototype column, because this is a Studio-internal fix.

Chat options, 390px light

chat options mobile light
chat options mobile light zoom

Schedule detail actions, 390px light and dark




Chat options, 390px dark


Learning refresh (unchanged, workaround removed), 390px and desktop, light and dark






Desktop 1280px, light and dark (unchanged)





Closes #2366
Part of #2201
Part of #2210

🤖 Generated with Claude Code

peppescg and others added 2 commits October 15, 2026 19:19
Measure the drawn icon of a Button inside a TooltipTrigger (learning
refresh) and a DropdownMenuTrigger (schedule actions, chat options) at
1280px and 390px. On phones the bare glyphs inside a DropdownMenuTrigger
draw at 18px because the trigger's data-slot replaces the Button's and
the phone rule misses them; the refresh icon holds 20px only through its
per-site size-4.

Refs #2366

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…gers

A Radix trigger with asChild passes its own data-slot through props, and
Button spreads props after its data-slot="button", so the trigger's slot
wins. The phone rule in styles.css keyed on [data-slot="button"] and
missed every Button inside a TooltipTrigger or DropdownMenuTrigger: their
bare glyphs drew at 18px on phones instead of 20px.

Button now also sets data-button after the spread, so no merged prop can
replace it, and the phone rule keys on [data-button]. data-slot keeps
naming the outermost part, as the trigger tests expect.

- Remove the size-4 workaround on the learning refresh icon.
- The learning pin reads the phone rule's selector list from styles.css
  instead of a copied string literal.
- The browser journeys now expect 20px on phones for all three triggers.

Closes #2366

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@kantord kantord left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for fixing this at the root rather than per call site. Putting data-button after the props spread is the right shape: data-slot keeps naming the outermost part, and the phone rule no longer depends on whether a trigger replaced it. I also checked that nothing else in apps/ keys on [data-slot="button"] (only styles.css, button.tsx and fonts.test.ts, all updated here). Approving, with a few non-blocking notes:

  • Heads-up for whoever tests on a phone: every bare icon in a Button inside an asChild trigger now draws at 20px instead of 18px. That is the intent, but it is a visible change across the app.
  • Elements that only borrow buttonVariants classes, and Toggle, still don't get data-button, so they still need size-4 per icon (#2362 does this). A one-line note in the PR or the code comment would help the next reader.
  • The new Playwright spec has three journeys with heavy mock setup for behaviour the unit tests already pin. Not a correctness issue, just maintenance cost.

Fully or partially written by an AI agent.

@peppescg
peppescg merged commit ce7d4d3 into main Oct 16, 2026
31 checks passed
@peppescg
peppescg deleted the fix/studio-trigger-button-icon-size branch October 16, 2026 08:56
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Oct 20, 2026
2 tasks
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.

Studio: keep the phone icon size for Buttons inside asChild triggers

2 participants