-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
Selected button breathing effect on Chrome #16976
Comments
In Chrome, the last clicked button gets keyboard focus (you can tab to the previous or next button), but the keyboard focus indicator isn't shown until you leave and return to the page. In Firefox, clicking a button does not focus it, but keyboard focus works as expected when used separately. |
I was working on mui/material-ui#16976, by luck, the concern was already taking care of in WICG#167. In the process of applying the diff, I have found this strange call to clearTimeout—I believe it's not needed.
@iaarnio Yeap, I think that they would agree with you: WICG/focus-visible#167. I would propose the same fix here. What do you think of? diff --git a/packages/material-ui/src/utils/focusVisible.js b/packages/material-ui/src/utils/focusVisible.js
index f20ddb884..e5d860f0d 100644
--- a/packages/material-ui/src/utils/focusVisible.js
+++ b/packages/material-ui/src/utils/focusVisible.js
@@ -47,7 +47,18 @@ function focusTriggersKeyboardModality(node) {
return false;
}
-function handleKeyDown() {
+/**
+ * Keep track of our keyboard modality state with `hadKeyboardEvent`.
+ * If the most recent user interaction was via the keyboard;
+ * and the key press did not include a meta, alt/option, or control key;
+ * then the modality is keyboard. Otherwise, the modality is not keyboard.
+ * @param {KeyboardEvent} event
+ */
+function handleKeyDown(event) {
+ if (event.metaKey || event.altKey || event.ctrlKey) {
+ return;
+ }
+
hadKeyboardEvent = true;
}
@@ -57,7 +68,6 @@ function handleKeyDown() {
* This avoids the situation where a user presses a key on an already focused
* element, and then clicks on a different element, focusing it with a
* pointing device, while we still think we're in keyboard modality.
- * @param {Event} e
*/
function handlePointerDown() {
hadKeyboardEvent = false;
@@ -119,7 +129,6 @@ function handleBlurVisible() {
window.clearTimeout(hadFocusVisibleRecentlyTimeout);
hadFocusVisibleRecentlyTimeout = window.setTimeout(() => {
hadFocusVisibleRecently = false;
- window.clearTimeout(hadFocusVisibleRecentlyTimeout);
}, 100);
} Do you want to submit a pull request? @mbrookes Did you try on Edge? |
That sounds like a bug in firefox. I cannot reproduce this on firefox 68.0.1 (64-bit) ubuntu 19.04. With "focus" do you mean That being said with experimental web features enabled in chrome I get no focus-visible (native or polyfilled) when switching tabs/windows after click. If we make any change it should be made after WICG/focus-visible#167 is resolved. Any discussion should happen there. |
I have seen that WICG/focus-visible#184 was merged recently (after our last update of the logic on Material-UI side), |
I'd forgotten that our corporate build forces us onto 60.8.0esr, so not a valid test. And Safari is behaving correctly today. 🤷♂ |
I was working on mui/material-ui#16976, by luck, the concern was already taking care of in #167. In the process of applying the diff, I have found this strange call to clearTimeout—I believe it's not needed.
Can I work on this PR kindly. |
No objection from my part. It's slightly opinionated given the @robdodson Would you recommend Material-UI to apply WICG/focus-visible#184 in its codebase? Thanks. |
@adeelibr are you working on this? |
Yes, i am just waiting on the go ahead from @robdodson |
I'm personally in favor of moving forward because 1. on Chrome, if you click a button (it gives it the focus), if you cmd+tab to move away and come back, you won't get the focus outline. 2. We can easily revert based on WICG/focus-visible#167 outcome. |
okay, picking this ticket up then 👍 |
|
Current Behavior 😯
Selected button has weird breathing effect. This happens on Chrome (on MacOS).
It will becomes visible when browser is switched to background application and then back again (i.e. when it gets focus again).
Expected Behavior 🤔
Button should be visible without breathing effect. The same way it is when Chrome has focus all the time and is not switched to background.
Steps to Reproduce 🕹
Steps:
The lighter color bubble also expands and shrinks like inhale and outhale of breathing:
Your Environment 🌎
MacOS Mojave 10.14.6 (18G87)
Chrome Version 76.0.3809.100 (Official Build) (64-bit)
I cannot reproduce the same using Safari or Firefox so could be also browser issue.
The text was updated successfully, but these errors were encountered: