Skip to content

Core: Zoom tool refinements - Hide reset button when value is initial#33635

Merged
Sidnioulz merged 8 commits intostorybookjs:nextfrom
superLipbalm:fix/33614-hide-reset-button-when-value-is-initial
Mar 3, 2026
Merged

Core: Zoom tool refinements - Hide reset button when value is initial#33635
Sidnioulz merged 8 commits intostorybookjs:nextfrom
superLipbalm:fix/33614-hide-reset-button-when-value-is-initial

Conversation

@superLipbalm
Copy link
Copy Markdown
Contributor

@superLipbalm superLipbalm commented Jan 25, 2026

#33614

What I did

The reset button is no longer displayed when Zoom is in its initial state.
I used visibility: hidden to ensure the menu width remains consistent even when the button is hidden.
Since the styling isn't complex and many parts already use inline styles, I added them inline to make it easier to see which styles apply under which conditions.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

Caution

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

reset button

I confirmed that the button disappears when the initial value is set.
I also confirmed that the menu width does not change based on the button's visibility, as intended.

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • New Features

    • Introduced an improved zoom reset control that appears only when zoom is not at its default level.
  • Refactor

    • Zoom reset behavior updated: the control is now hidden at the default zoom level instead of being disabled, creating a cleaner interface.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 25, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Replaced the reset button in the zoom tool with a new styled ZoomResetButton that receives a $isInitialValue prop and is hidden (via CSS/visibility) when at the initial zoom level; click still resets zoom to INITIAL_ZOOM_LEVEL and ARIA attributes adjusted accordingly.

Changes

Cohort / File(s) Summary
Zoom Reset Button Refactor
code/core/src/manager/components/preview/tools/zoom.tsx
Added ZoomResetButton (styled, with $isInitialValue prop). Replaced previous ActionList.Button in the Zoom after slot; changed reset control from disabled to hidden when at initial zoom and set aria-hidden / visibility via $isInitialValue.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs


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.

Copy link
Copy Markdown
Member

@Sidnioulz Sidnioulz 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 taking this on! Could you please apply the fix by not rendering the item instead of hiding it?

@storybook-app-bot
Copy link
Copy Markdown

storybook-app-bot bot commented Jan 26, 2026

Package Benchmarks

Commit: 2dc2b04, ran on 2 March 2026 at 04:35:35 UTC

The following packages have significant changes to their size or dependencies:

@storybook/addon-vitest

Before After Difference
Dependency count 2 2 0
Self size 402 KB 379 KB 🎉 -23 KB 🎉
Dependency size 338 KB 338 KB 🎉 -3 B 🎉
Bundle Size Analyzer Link Link

storybook

Before After Difference
Dependency count 49 49 0
Self size 20.19 MB 20.39 MB 🚨 +201 KB 🚨
Dependency size 16.52 MB 16.52 MB 🎉 -2 B 🎉
Bundle Size Analyzer Link Link

@storybook/nextjs

Before After Difference
Dependency count 535 535 0
Self size 648 KB 646 KB 🎉 -2 KB 🎉
Dependency size 59.90 MB 59.93 MB 🚨 +34 KB 🚨
Bundle Size Analyzer Link Link

@storybook/nextjs-vite

Before After Difference
Dependency count 92 92 0
Self size 1.12 MB 1.12 MB 🎉 -383 B 🎉
Dependency size 22.47 MB 22.50 MB 🚨 +33 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-native-web-vite

Before After Difference
Dependency count 124 124 0
Self size 30 KB 30 KB 🎉 -126 B 🎉
Dependency size 23.75 MB 23.79 MB 🚨 +33 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-vite

Before After Difference
Dependency count 82 82 0
Self size 35 KB 35 KB 🎉 -106 B 🎉
Dependency size 20.25 MB 20.28 MB 🚨 +33 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-webpack5

Before After Difference
Dependency count 274 274 0
Self size 24 KB 24 KB 🎉 -86 B 🎉
Dependency size 44.56 MB 44.60 MB 🚨 +34 KB 🚨
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 183 183 0
Self size 779 KB 775 KB 🎉 -4 KB 🎉
Dependency size 67.37 MB 67.52 MB 🚨 +154 KB 🚨
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 176 176 0
Self size 32 KB 30 KB 🎉 -2 KB 🎉
Dependency size 65.89 MB 66.09 MB 🚨 +201 KB 🚨
Bundle Size Analyzer Link Link

create-storybook

Before After Difference
Dependency count 50 50 0
Self size 1.04 MB 1000 KB 🎉 -44 KB 🎉
Dependency size 36.72 MB 36.92 MB 🚨 +201 KB 🚨
Bundle Size Analyzer node node

@storybook/preact

Before After Difference
Dependency count 2 2 0
Self size 23 KB 16 KB 🎉 -7 KB 🎉
Dependency size 32 KB 32 KB 🎉 -3 B 🎉
Bundle Size Analyzer Link Link

@storybook/react

Before After Difference
Dependency count 58 57 🎉 -1 🎉
Self size 1.19 MB 1.23 MB 🚨 +36 KB 🚨
Dependency size 13.20 MB 12.94 MB 🎉 -264 KB 🎉
Bundle Size Analyzer Link Link

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.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@code/core/src/manager/components/preview/tools/zoom.tsx`:
- Around line 84-93: The input shifts because NumericInput only renders the
after slot when truthy; when value === INITIAL_ZOOM_LEVEL the ActionList.Button
(reset) unmounts and its paddingRight is removed. Fix by always rendering the
after slot as a fixed-width container (or an empty placeholder) inside
NumericInput’s after prop so the space is reserved even when INITIAL_ZOOM_LEVEL
hides the ActionList.Button; update the zoom control (the conditional around
ActionList.Button that uses INITIAL_ZOOM_LEVEL and zoomTo) to render a
placeholder element of equal width instead of null.

Copy link
Copy Markdown
Member

@Sidnioulz Sidnioulz left a comment

Choose a reason for hiding this comment

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

The edit logic is good, just need to change the code a bit to ensure the menu layout is stable.

Please re-request a review once changes are done so I get notified 🙏

@superLipbalm
Copy link
Copy Markdown
Contributor Author

547521b
@Sidnioulz
I'm sorry for being late.
I've modified the menu layout to stay stable.
As suggested, passing the hidden prop now applies visibility: hidden, hiding it while still occupying space.

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@code/core/src/components/components/Button/Button.tsx`:
- Around line 142-143: The Button component is forwarding the semantic HTML
hidden attribute to the DOM; change the styling-only prop to a transient prop
(rename hidden → $hidden) so it won't be forwarded. Update the StyledButton
props/interface to use $hidden, update its style logic (visibility rules that
referenced hidden) to use $hidden, add a shouldForwardProp (or rely on transient
prop behavior) to prevent forwarding, and update the Button JSX where you pass
hidden to instead pass $hidden while keeping the public API for consumers (e.g.,
keep the Button prop named hidden and map it internally to $hidden when
rendering StyledButton).

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bbd480e and 547521b.

📒 Files selected for processing (2)
  • code/core/src/components/components/Button/Button.tsx
  • code/core/src/manager/components/preview/tools/zoom.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • code/core/src/manager/components/preview/tools/zoom.tsx

Copy link
Copy Markdown
Member

@Sidnioulz Sidnioulz left a comment

Choose a reason for hiding this comment

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

Could you please make the change only by passing Emotion classes and HTML attributes in zoom.tsx, without any change to Button?

Button is a widely used public component so changes to its public API need to go through a much tougher review process. Here, we don't want to change its API.

… utilize it for the zoom reset button."

This reverts commit 547521b.
… conditional CSS visibility using a new styled component.
… zoom reset button when at initial zoom level"

This reverts commit 93f30d9.
@superLipbalm superLipbalm requested a review from Sidnioulz March 2, 2026 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants