-
-
Notifications
You must be signed in to change notification settings - Fork 568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: prevent list items from overflowing Markdown content #1736
fix: prevent list items from overflowing Markdown content #1736
Conversation
🦋 Changeset detectedLatest commit: b82f34d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for jumping into this so quickly @julien-deramond!
I did some quick testing across the Starlight docs to investigate the potential for regressions (hard to be sure for all user content, so I’m hoping our range of content is a good enough test case).
I did find one specifically in our <Tabs>
component that should never wrap and instead scroll horizontally when they overflow:
I guess we’ll need to override the overflow-wrap: anywhere
for that component. It also gives a small indication that this could have an impact on user components in theory.
It makes me wonder if our global rule setting this should be scoped to the Markdown content and use :not(:where(.not-content *))
like the other rules to make it easier for users to escape that styling if needed. This rule here:
Yes, if it is difficult to measure the impact on Starlight side, we can be sure that it will have an impact on users' components.
My first version was adding I'd be in favor to scope it to the Markdown content. It would seem to be the most maintainable approach for the Starlight core team, and maybe also less opinionated and/or impactful for the users and their components, yeah. |
Thanks for the great contribution. We reviewed this PR with a lot of eyes/devices/browsers today in Astro Talking & Doc'ing session. To do so, we had everyone browse random pages on various Starlight websites (Starlight Docs, Astro Docs, SST Ion docs and Knip Docs) where I implemented ahead of time the suggested fix from this PR. With exactly the suggested changes from this PR, no extra issue except the one spotted by Chris regarding the We tried a slight variation of the selector ( Did not play more than that yet with the selector, but I guess it will need a bit more tweaking to handle those cases. |
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
Sorry for the delay, I was off and also overwhelmed by other OSS repos. Based on #1736 (comment) and #1736 (review), I've reset the This can be tested out here:
With these modifications, the PR should cover all use cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for following up on this @julien-deramond! Just played around with it again and I think this is indeed the best approach.
I do wonder if our generic set-up for this in reset.css
ought really also to be moved to markdown.css
:
starlight/packages/starlight/style/reset.css
Lines 35 to 44 in d33bbc7
p, | |
h1, | |
h2, | |
h3, | |
h4, | |
h5, | |
h6, | |
code { | |
overflow-wrap: anywhere; | |
} |
In a quick check, I think the only element this currently applies to which is outside of the Markdown content is the page title.
But that can happen as follow-up work to keep this PR focused on the specific fix.
@@ -65,6 +65,7 @@ const { html, panels } = processPanels(panelHtml); | |||
border-bottom: 2px solid var(--sl-color-gray-5); | |||
color: var(--sl-color-gray-3); | |||
outline-offset: var(--sl-outline-offset-inside); | |||
overflow-wrap: initial; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree that this makes sense given how overflow-wrap
is inherited 👍
Yes, I can take a look in a follow-up PR to ease the review and evaluate the impacts. Whenever this PR is accepted, feel free to ping me so that I can remove the extra testing data before merging :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think everything looks good to me!
We can remove the background colour and the test content I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect — this looks good to me!
Would you want to write a changeset for the changelog (you can use the link in the bot comment above to add one), or would you prefer me to take care of that?
Tried to add one thanks to your doc via b82f34d. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for the thoroughness working out the solution @julien-deramond and @HiDeoo for running it through the Talking & Doc’ing testing machine 💖
Description
Context
This PR is an attempt to fix an issue reported in this Discord > starlight > Text overflow issue thread.
On iPhone XR, OP could see on a 414px width screen the following (at https://0d6fe6ee.chart-docs.pages.dev/charts/dependency/kube-state-metrics/) which results in a horizontal scrollbar:
It can also be observed, at least on macOS with Safari and Chrome.
Changes
As you can see in the deployed documentation, I've tested some long links in the regular content, but also in ordered and unordered lists. Regular content is fine, while the long links in the lists are overflowing.
The idea here is to rely on the same fixes that happened in #756 and #814 based on the use of
overflow-wrap: anywhere
.Not knowing in detail the codebase of Starlight, I suppose that reducing the scope to
.sl-markdown-content li
is acceptable (I've added a reddish background for visual manual regression testing). Indeed, adding this rule directly in thereset.css
might have some unexpected repercussions.Here's the rendering before the fix.
Here's the rendering after the fix (directly accessible at https://starlight-git-fork-julien-deramond-main-jd-bab67d-astrodotbuild.vercel.app/guides/authoring-content/):
Non-regression testing
I'm sorry but I haven't tested yet some impacts that would maybe need a stricter CSS rule, and I'll be off for 1 week tomorrow.
Some use cases that could be impacted: