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
base: main
Are you sure you want to change the base?
fix: prevent list items from overflowing Markdown content #1736
Conversation
|
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:
https://github.com/withastro/starlight/blob/main/packages/starlight/style/reset.css#L35-L44
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. |
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: