-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
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
[core] Remove useIsFocusVisible util #42467
Conversation
Netlify deploy previewhttps://deploy-preview-42467--material-ui.netlify.app/ Link: parsed: -2.54% 😍, gzip: -2.82% 😍 Bundle size reportDetails of bundle changes (Toolpad) |
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.
Just a precaution, have you tested that all these components behave identically once moving to use the :focus-visible
pseudo selector in the oldest browsers we support? Just to make sure there won't introduce some subtle breaking changes with this.
I tested all browsers, both minimally supported and latest versions. The only thing "not working" is the Link's focus visible in Firefox 115, but that's not working on This is ready for review 😊 |
1dce511
to
16dddbb
Compare
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.
Very nice! Left some small comments and questions.
45f9abe
to
6c31464
Compare
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.
yay!
/** | ||
* Returns a boolean indicating if the event's target has :focus-visible | ||
*/ | ||
export default function isFocusVisible(element: Element): boolean { |
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 would have expected this to come from Base UI.
?
export default function isFocusVisible(element: Element): boolean { | |
// TODO import from Base UI | |
export default function isFocusVisible(element: Element): boolean { |
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.
As mentioned in the description: "ideally, we would use the :focus-visible
pseudo-selector directly, but that would mean removing the focusVisible
classes and refactoring many components."
The isFocusVisible
function is an intermediary step, so I don't think we should implement it in Base UI. When we reimplement the look of the library, we should use :focus-visible
directly, deprecate the focusVisible
classes, and eventually remove this function.
Part of #40958
Closes: #14420
As
:focus-visible
is now supported in all our supported browsers (reference), we can remove this utility and rely completely on:focus-visible
.This is an intermediate step: ideally, we would use the
:focus-visible
pseudo-selector directly, but that would mean removing thefocusVisible
classes and refactoring many components.