Skip to content
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][3.4.3] VDialog (retain-focus prop) Tab focus is kept on the activator #18779

Closed
ErneMiralles92 opened this issue Nov 27, 2023 · 1 comment
Assignees
Labels
C: VDialog VDialog T: bug Functionality that does not work as intended/expected
Milestone

Comments

@ErneMiralles92
Copy link

Environment

Vuetify Version: 3.4.3
Vue Version: 3.3.7
Browsers: Chrome 119.0.0.0
OS: Mac OS 10.15.7

Steps to reproduce

Open the dialog by clicking on a v-text-field.
The dialog is opened but the focus is kept in the v-text-field.
The same happens if the dialog is opened from a button, to see it more clearly open the dialog using the keyboard to click the button(Using tab key and then space or enter key), the button keeps the focus-active styling.

Expected Behavior

If retain-focus prop is true(it is by default):
Tab focus should return to the first child of the dialog by default.

Actual Behavior

The focus is kept on the activator.

Reproduction Link

https://play.vuetifyjs.com/#...

@Redpoint1
Copy link

The problem is in the focusing element.

https://github.com/vuetifyjs/vuetify/blob/master/packages/vuetify/src/components/VDialog/VDialog.tsx#L93
overlay.value!.contentEl?.focus({ preventScroll: true })

The overlay.value.contentEl doesn't have tabindex="-1" and therefore focus() does nothing (by default div can't be focused unless tabindex is present). The closest element that has tabindex="-1" is overlay.value.$el.

So you need to add tabindex="-1" to the overlay.value.contentEl or use focus() on overlay.value.$el instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment