Docs: add paddingLeft to OcticonHeaders so anchor icon is not clipped in light theme#33957
Conversation
…ipped The docs heading anchor link (OcticonAnchor) uses float:left with marginLeft:-24px to position itself to the left of the heading text. Without paddingLeft on the heading itself, this negative-margin float extends outside the element's content box, causing the icon to be clipped by the parent container in the light theme. Adding paddingLeft:'24px' to OcticonHeaders creates the space the floating anchor needs to be fully visible, mirroring the approach used by GitHub's Markdown heading anchors. Closes storybookjs#31505
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA styling adjustment added left padding to OcticonHeaders in the MDX documentation blocks. This reserves space for a floating anchor icon to prevent visual clipping without modifying any functional logic or control flow. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 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. Comment |
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 49 | 49 | 0 |
| Self size | 20.19 MB | 20.42 MB | 🚨 +228 KB 🚨 |
| Dependency size | 16.52 MB | 16.52 MB | 0 B |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 183 | 183 | 0 |
| Self size | 779 KB | 779 KB | 0 B |
| Dependency size | 67.37 MB | 67.60 MB | 🚨 +228 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 176 | 176 | 0 |
| Self size | 32 KB | 32 KB | 🎉 -36 B 🎉 |
| Dependency size | 65.89 MB | 66.12 MB | 🚨 +228 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
create-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 50 | 50 | 0 |
| Self size | 1.04 MB | 1.04 MB | 0 B |
| Dependency size | 36.71 MB | 36.94 MB | 🚨 +228 KB 🚨 |
| Bundle Size Analyzer | node | node |
Sidnioulz
left a comment
There was a problem hiding this comment.
Thanks for the PR!
Unfortunately, it has very visible side effects. All heading text gets moved to the right, and is no longer aligned to the content.
For this bug, we'll want to fix the underlying CSS conflict issue described in the GitHub issue instead of changing text alignment.
Please make sure to test your changes in the Storybook UI with yarn task compile && yarn storybook:ui prior to pushing changes. Please also make sure to correctly fill in the "Manual testing" part of the PR template going forward.
|
@mixelburg FYI I could not reproduce the original issue in #28259. If you are able to reproduce it, could you please provide a link to a reproduction repository? This would be very helpful. We also have a fix by Claude that looks reasonably smart to me but we need a repro case to validate it. Thanks, |
This comment was marked as low quality.
This comment was marked as low quality.
Thanks for checking if you could repro! |
Closes #31505
What I did
When the docs addon renders headings with anchor icons (
OcticonAnchor), the anchor is positioned usingfloat: leftwithmarginLeft: '-24px'. This negative-margin approach requires the heading itself to have at least 24px of left padding so the floating icon has room to appear without being clipped by the parent container.In the light theme the heading had no left padding, so the icon was cut off. The dark theme happened to have extra left space from a parent container, which masked the bug.
The fix adds
paddingLeft: '24px'to theOcticonHeadersstyled components (the same approach used by GitHub's Markdown heading anchors).Before (light theme): anchor icon cut off on the left side
After (light theme): anchor icon fully visible, matching dark-theme behaviour
Summary by CodeRabbit