Improve the fallback example for :focus-visible#19993
Merged
Conversation
Contributor
Preview URLsFlawsNone! 🎉 External URLsURL: No new external URLs (this comment was updated 2022-08-28 12:45:48.545648) |
Contributor
Author
|
Commits are added very quickly to the |
Contributor
Author
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”. |
teoli2003
suggested changes
Aug 28, 2022
Co-authored-by: Jean-Yves Perrier <jypenator@gmail.com>
Co-authored-by: Jean-Yves Perrier <jypenator@gmail.com>
Co-authored-by: Jean-Yves Perrier <jypenator@gmail.com>
Co-authored-by: Jean-Yves Perrier <jypenator@gmail.com>
teoli2003
approved these changes
Aug 28, 2022
Contributor
Author
|
@teoli2003 thanks 🙂 |
goshdarnheck
pushed a commit
to goshdarnheck/content
that referenced
this pull request
Sep 7, 2022
* 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 <jypenator@gmail.com> * Improve code comment Co-authored-by: Jean-Yves Perrier <jypenator@gmail.com> * Improve fallback comment Co-authored-by: Jean-Yves Perrier <jypenator@gmail.com> * Remove unwanted part Co-authored-by: Jean-Yves Perrier <jypenator@gmail.com> * Fix test failure (sorry) Co-authored-by: Jean-Yves Perrier <jypenator@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improved code example for fallback on
:focusand 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
:focusat all, so older browsers would just have a native focus outline.This code works well in newer browsers and fallbacks to
:focusin older ones as expected. Checked in Safari 14.1:Kooha-2022-08-24-19-42-56.mp4
Metadata