-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
[Bug Report] Tab focus from v-select returns to the first focusable element #6608
Comments
This issue is also happening on chrome windows 10 not only v-select but also on v-autocomplete or any dropdown input. When the user selecting an item with the help of the mouse and then press tab key is not working properly as expected. When the mosue click to select an item and tab three times then focus moving onto first input. |
Is there any work around for this? |
Any news about this? A month has passed and there is still no work around for this!!! |
It seems that the order in which the events are emitted by the browser are disparate, so when one component lost focus and other receive it may be diffferent in sequence between disparate browsers. So, the solution could be to give a chance to the browser to do its work and then process the event to work around this problem. A simple work around is to extends for example import { VAutocomplete } from "vuetify/lib";
export default {
name: "your-autocomplete",
extends: VAutocomplete,
methods: {
blur(e) {
setTimeout(() => VAutocomplete.methods.blur.call(this, e), 0);
}
}
}; On MS Edge this work around works, I need to check it on Safari: by the way, this is a pen to prove that works: https://codepen.io/userquin/pen/rRaYgP |
also working on safari macosx |
Blame: 8a2a1a1 @johnleider that logic needs to be in a separate method, this fix is also emitting blur twice. |
From w3c, event bubbling:
|
I have version 1.5.5, the code on /** @public */
blur: function blur(e) {
this.isMenuActive = false;
this.isFocused = false;
this.$refs.input && this.$refs.input.blur();
this.selectedIndex = -1;
this.onBlur(e);
},
/** @public */
activateMenu: function activateMenu() {
this.isMenuActive = true;
},
onBlur: function onBlur(e) {
this.$emit('blur', e);
}, If I just change my autocomplete to this one, just only 1 blur event is fired: import { VAutocomplete } from "vuetify/lib";
export default {
name: "your-autocomplete",
extends: VAutocomplete,
methods: {
blur() {
setTimeout(this.handleBlur, 0);
},
handleBlur() {
this.isMenuActive = false;
this.isFocused = false;
this.selectedIndex = -1;
}
}
}; |
The above fix works for the autocomplete, any solution for the VSelects being broken? |
Just extends from import { VSelect } from "vuetify/lib";
export default {
name: "your-select",
extends: VSelect,
methods: {
blur() {
setTimeout(this.handleBlur, 0);
},
handleBlur() {
this.isMenuActive = false;
this.isFocused = false;
this.selectedIndex = -1;
}
}
}; |
also the fix is for 1.5.5, not tested on 1.5.6, 1.5.7 |
well, it is a little more complicated, just because VSelect is a functional wrapper over VSelect, so we need to import import VSelect from "vuetify/lib/components/VSelect/VSelect";
// work around for https://github.com/vuetifyjs/vuetify/issues/6608
export default {
name: "your-select",
extends: VSelect,
data: () => ({
blurHandled: false
}),
methods: {
blur() {
if (!this.blurHandled) {
setTimeout(this.handleBlur, 0);
}
},
onTabDown(e) {
this.blurHandled = true;
setTimeout(() => this.handleTabDown(e), 0);
},
handleBlur() {
this.isMenuActive = false;
this.isFocused = false;
this.selectedIndex = -1;
this.$nextTick(() => (this.blurHandled = false));
},
handleTabDown(e) {
if (this.isMenuActive) {
VSelect.options.methods.onTabDown.call(this, e);
} else {
this.handleBlur();
}
}
}
}; |
Thanks, that fix works for 1.57 in IE 11. |
a simplified version of import VSelect from "vuetify/lib/components/VSelect/VSelect";
// work around for https://github.com/vuetifyjs/vuetify/issues/6608
export default {
name: "your-select",
extends: VSelect,
methods: {
blur() {},
onTabDown(e) {
setTimeout(() => this.handleTabDown(e), 0);
},
handleBlur() {
this.isMenuActive = false;
this.isFocused = false;
this.selectedIndex = -1;
},
handleTabDown(e) {
if (this.isMenuActive) {
VSelect.options.methods.onTabDown.call(this, e);
} else {
this.handleBlur();
}
}
}
}; |
@KaelWD , will this be fixed any time soon? |
both fixes tested on windows 10: edge. chrome and firefox and macosx: chrome, firefox and safari |
@KaelWD I think vuetify team must review focus/blur behavior in deep, not just for these 2 components. Another example (not yet reported): I use a |
ok, I just have found what's the problem, it is a problem in the As you can see in the next image (MS Edge), once the tab key is pressed on What happens here: well, the date component just remove the mask on blur, but watch: {
/**
* Make sure the cursor is in the correct
* location when the mask changes
*/
mask () {
... (some code)
this.$nextTick(() => {
this.$refs.input.value = newValue
this.setCaretPosition(selection)
})
}
}
methods: {
setCaretPosition (selection) {
this.selection = selection
window.setTimeout(() => {
this.$refs.input && this.$refs.input.setSelectionRange(this.selection, this.selection)
}, 0)
},
.... In the case of MS Edge, just works and if we press tab key again, the focus moves to the next one bellow On Safari, the problem is that when you call So my work around is very simple: import VTextField from "vuetify/lib/components/VTextField/VTextField";
export default {
name: "my-maskable-text-field",
extends: VTextField,
methods: {
setCaretPosition(selection) {
this.selection = selection;
setTimeout(() => {
this.$refs.input &&
this.isFocused && /*<=== fix here */
this.$refs.input.setSelectionRange(this.selection, this.selection);
}, 0);
}
}
}; |
This comment has been minimized.
This comment has been minimized.
Any update on this? It's a showstopper for us :( |
Using this for VCombobox which is also affected by this bug:
They apparently changed it to |
This is resolved with 5fa6a68 . Thank you to everyone for your patience on this. |
So these fixes are not going to be in |
For all who make it this far - I have put up the PR to v1.5 here: #10620. Once this is merged then it should be fixed for all of us who are unable to upgrade to 2.x at this time. Update It was merged so v1.5.23 has the tabbing fix I applied now. |
This is still happening in Safari with Vuetify 2.5.0, although it's supposed to be fixed according to commit history. Am I missing something? |
We kindly ask users to not comment on closed/resolved issues. If you believe that this issue has not been correctly resolved, please create a new issue showing the regression or create a new discussion. If you have any questions, please reach out to us in our Discord community. |
Versions and Environment
Vuetify: 1.5.1
Vue: 2.6.6
Browsers: Safari, Internet Explorer
OS: Mac OS 10.13.6, Windows
Steps to reproduce
Using macOS Safari 12.0.3 or IE11.
It can be confirmed in the sample of the official document.
In Google Chrome, tab focus move from v-select is works normally.
Expected Behavior
Tab focus move to next focusable element from v-select in Safari and IE11
Actual Behavior
Tab focus does not move to next focusable element from v-select in Safari and IE11
Reproduction Link
https://codepen.io/anon/pen/RdwyQQ?editors=1010
The text was updated successfully, but these errors were encountered: