Code: Fix inline code blocks inside links removing link affordance#33903
Conversation
Enhance the appearance of code elements within links by applying underline and spacing styles. This change ensures better visibility and consistency across typography components.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdds nested styling so inline Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
code/core/src/components/components/typography/DocumentWrapper.tsx (1)
69-82: Consider extracting shared link-code styles.The
& codestyling block is now duplicated identically in bothA.tsxandDocumentWrapper.tsx. You could extract this to a shared constant (e.g., inlib/common.ts) for DRY consistency:export const linkCodeStyles = { color: 'inherit', textDecoration: 'underline', textDecorationThickness: '1px', padding: 0, '&::before': { content: '"\\00a0"', fontSize: '0.5em', }, '&::after': { content: '"\\00a0"', fontSize: '0.5em', }, };This is optional—the current duplication is minimal and clear.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@code/core/src/components/components/typography/DocumentWrapper.tsx` around lines 69 - 82, Extract the duplicated '& code' style object into a shared exported constant (e.g., linkCodeStyles) and replace the inline objects in DocumentWrapper (component DocumentWrapper) and A (component A) with a reference to that constant; ensure the constant exports the same properties (color, textDecoration, textDecorationThickness, padding, '&::before', '&::after') and is imported where used so both components consume the single source of truth.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@code/core/src/components/components/typography/DocumentWrapper.tsx`:
- Around line 69-82: Extract the duplicated '& code' style object into a shared
exported constant (e.g., linkCodeStyles) and replace the inline objects in
DocumentWrapper (component DocumentWrapper) and A (component A) with a reference
to that constant; ensure the constant exports the same properties (color,
textDecoration, textDecorationThickness, padding, '&::before', '&::after') and
is imported where used so both components consume the single source of truth.
|
Thanks for trying to fix my issue @yatishgoel! I haven't figured out how to test locally, but I'm fairly certain that setting |
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 184 | 184 | 0 |
| Self size | 780 KB | 780 KB | 🚨 +84 B 🚨 |
| Dependency size | 67.67 MB | 67.68 MB | 🚨 +10 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 177 | 177 | 0 |
| Self size | 32 KB | 32 KB | 🚨 +36 B 🚨 |
| Dependency size | 66.19 MB | 66.20 MB | 🚨 +10 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
Sidnioulz
left a comment
There was a problem hiding this comment.
Thanks for the PR @yatishgoel! 🙇
Could you please edit stories as mentioned under, so that we have UI tests and non-regression tests for the change you made? I'll then send this to our designer for a design review.
Thanks
Added examples of inline code within links to the Markdown and DocumentWrapper stories for better demonstration of typography features. Adjusted padding styles in DocumentWrapper and A components for improved layout consistency.
Thanks for the feedback @Sidnioulz! I've made the following changes:
|
|
Thanks @yatishgoel for adding the stories! We have to get #33139 merged before because it's gonna break your PR. I'll put it in my backlog and get back to you afterward with instructions. The stories will help us get a UI outcome to reflect on once we rebase your PR branch :) Talk to you soon! |
|
@yatishgoel we've merged the other PR that affected link styles, could you please have a look at the conflicts? Also, ideally we'd want to ensure the same text decoration thickness is used as in the other PR (as that was reviewed by our design team). Thanks! |
@Sidnioulz can you please confirm whether the |
Hey there! Yes, I believe we want to go for the same underline. |
Sidnioulz
left a comment
There was a problem hiding this comment.
Thanks for bearing with us and seeing this to completion, @yatishgoel 🙏 Great work.
Thank you for the guidance and patience throughout, @Sidnioulz ! Happy to contribute 🙌 |


Closes #33901
What I did
Fixed a CSS specificity issue where inline code blocks (
<code>) inside links (<a>) lost all link styling (color, underline),making them appear unclickable.
Added an
'& code'CSS rule to both theAstyled component and theDocumentWrappercomponent so that code inside links inheritsthe link color, displays an underline, and uses pseudo-elements for spacing (instead of padding, which breaks the underline).
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
[`inline-code`](https://example.com)Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake 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/coreteam 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