Skip to content

[Bug Report][2.6.9] Hidden inputs break v-dialog focus trap #15745

@shengslogar

Description

@shengslogar

Environment

Vuetify Version: 2.6.9
Vue Version: 2.7.10
Browsers: Chrome 105.0.0.0
OS: Mac OS 10.15.7

Steps to reproduce

Place any <input type="hidden"> inside a <v-dialog>.

Expected Behavior

Focus is trapped within dialog.

Actual Behavior

Focus trap breaks and background elements are focusable.

Reproduction Link

https://codepen.io/shengslogar/pen/oNdjWNo

Other comments

This is the result of the query selector here:

// Find and focus the first available element inside the dialog
const focusable = this.$refs.dialog.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')
const el = [...focusable].find(el => !el.hasAttribute('disabled')) as HTMLElement | undefined
el && el.focus()

At a bare minimum, hidden inputs should be excluded from this selector. One might also consider aria-hidden inputs or display: none inputs (but the latter would require computing element dimensions which could result in a breaking change).

Metadata

Metadata

Assignees

Labels

C: VDialogT: bugFunctionality that does not work as intended/expected

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions