Avoid clipping focus indicator around site title (v2)#3058
Avoid clipping focus indicator around site title (v2)#3058delucis merged 6 commits intowithastro:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 381f2bb 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 |
✅ Deploy Preview for astro-starlight ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
Thanks for bringing back this PR @techfg! Perhaps I’m missing something but this doesn’t seem to actually do what’s described? If I add a As I mentioned previously, I don’t think this is an issue? The user agent default focus styles show up OK and if someone wants to add custom outline styles they can also add custom styles to the title to handle those if necessary. But either way this PR doesn’t seem to change things related to that. |
|
Hi @delucis - Thanks reviewing and sorry for the confusion here!
In short, you are only going to see a difference with this PR when you have title text and that text overflows. For example, a really long title or "long enough" when the viewport is narrower. In
Hopefully this helps better explain and demonstrate what this PR is trying to achieve. To see the effect:
integrations: [
starlight({
title:
+ 'Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight Starlight',
- 'Starlight',
logo: {
light: '/src/assets/logo-light.svg',
dark: '/src/assets/logo-dark.svg',
+ replacesTitle: false,
- replacesTitle: true,
},
*:focus,
*:focus:not(:focus-visible) {
outline: 1px solid transparent;
}
*:focus-visible {
outline: 1px solid green;
outline-offset: 1px;
} |
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>






Note
This is a replacement for #2714, which was relying on #2722 having been merged and shouldn't have been relying on it. See #2714 (comment).
Description
focus:visibleoutline ofsite-titlenot visible #2696overflow: hiddenand appliesmin-widthto ensure thetitle-wrapperis constrained to available space by flexbox. Additionally, it styles the title text (if its displayed) with elipses providing an improved UI so that text is no longer abruptly cut-off but rather gives an indication that there is more text that just isn't visible. If a logo is present, it will be automatically scaled and therefore doesn't require a container withoverflow: hidden. Tested in Edge, Chrome & Firefox.With a forced outline of
10px solid green:Before Desktop:

Before Mobile:

After Desktop:

After Mobile:

Important
In performing testing on this PR, I identified other issues related to the way the header is displayed with large images and/or long text.
Will create a separate issue to track those.Created #2715.