-
Notifications
You must be signed in to change notification settings - Fork 22.5k
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
Improve the fallback example for :focus-visible #19993
Conversation
Preview URLsFlawsNone! 🎉 External URLsURL: No new external URLs (this comment was updated 2022-08-28 12:45:48.545648) |
Commits are added very quickly to the |
It seems to me that he lost touch with the code in the last pull request that changes this example, because this text is not about stylized native buttons, but about buttons created using custom elements. But perhaps the repetition is redundant. I think we can somehow shorten the text. |
After replacing the custom button with a native button in the previous change to this example, the styles of the example now affect the native styles of the button. It is better to move the properties that change the appearance of the button itself into its general styles. In addition, this example has always been difficult to understand for beginners due to different styles for different focus pseudo-classes. Making the example look more realistic and practical will make it more useful for developers.
Maybe the title of the section should be changed to something like ”Providing a :focus fallback”. |
Co-authored-by: Jean-Yves Perrier <[email protected]>
Co-authored-by: Jean-Yves Perrier <[email protected]>
Co-authored-by: Jean-Yves Perrier <[email protected]>
Co-authored-by: Jean-Yves Perrier <[email protected]>
@teoli2003 thanks 🙂 |
* Improve the fallback example for :focus-visible After replacing the custom button with a native button in the previous change to this example, the styles of the example now affect the native styles of the button. It is better to move the properties that change the appearance of the button itself into its general styles. In addition, this example has always been difficult to understand for beginners due to different styles for different focus pseudo-classes. Making the example look more realistic and practical will make it more useful for developers. * Update the section heading * Improve text Co-authored-by: Jean-Yves Perrier <[email protected]> * Improve code comment Co-authored-by: Jean-Yves Perrier <[email protected]> * Improve fallback comment Co-authored-by: Jean-Yves Perrier <[email protected]> * Remove unwanted part Co-authored-by: Jean-Yves Perrier <[email protected]> * Fix test failure (sorry) Co-authored-by: Jean-Yves Perrier <[email protected]>
Summary
Improved code example for fallback on
:focus
and updated section text to match new code.Motivation
After replacing the custom button with a native button in the previous change to this example, the styles of the example now affect the native styles of the button. It is better to move the properties that change the appearance of the button itself into its general styles.
In addition, this example has always been difficult to understand for beginners due to different styles for different focus pseudo-classes. Making the example look more realistic and practical will make it more useful for developers.
Supporting details
@simevidas suggested the
@supports not selector()
method and noticed that setting/resetting background is causing the button to lose the native appearance on click.And @pepelsbey suggested not styling
:focus
at all, so older browsers would just have a native focus outline.This code works well in newer browsers and fallbacks to
:focus
in older ones as expected. Checked in Safari 14.1:Kooha-2022-08-24-19-42-56.mp4
Metadata