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.3.20] VDialog focus trap is broken by display: none inputs #18400

Open
shengslogar opened this issue Oct 4, 2023 · 0 comments
Assignees
Labels
C: VDialog VDialog T: bug Functionality that does not work as intended/expected

Comments

@shengslogar
Copy link

shengslogar commented Oct 4, 2023

Environment

Vuetify Version: 3.3.20
Vue Version: 3.3.4
Browsers: Chrome 117.0.0.0
OS: Mac OS 10.15.7

Steps to reproduce

Place any focusable element, as determined by the following code block (<input>, <a href>, etc.) with style="display: none" inside a VDialog.

export function focusableChildren (el: Element, filterByTabIndex = true) {
const targets = ['button', '[href]', 'input:not([type="hidden"])', 'select', 'textarea', '[tabindex]']
.map(s => `${s}${filterByTabIndex ? ':not([tabindex="-1"])' : ''}:not([disabled])`)
.join(', ')
return [...el.querySelectorAll(targets)] as HTMLElement[]
}

Expected Behavior

VDialog's focus trap should ignore visually hidden inputs.

Actual Behavior

Focus escapes VDialog and onto background elements.

Reproduction Link

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

Other comments

While I personally don't tend to hide elements by way of display: none, I ran into this issue when trying to embed a TinyMCE component into a dialog. Their WYSIWYG uses a hidden textarea.

I opened a similar issue (#15745) in v2. The resolution addressed this problem for negative tab indices and <input type="hidden">.

While another selector change could fix this single use case (for inline styles; we'd have to expensively calculate element dimensions otherwise), this approach might be revised to be more robust. For example, Headless UI targets a few extra selectors (including contenteditable), but also appears to check if document.activeElement is set to the element that we just tried to focus. If not, it moves on to the next one. This seems like it might provide a future catch-all to unfocusable edge cases.

@shengslogar shengslogar changed the title [Bug Report][3.3.20] VDialog focus trap is broken by display: none; inputs [Bug Report][3.3.20] VDialog focus trap is broken by display: none inputs Oct 4, 2023
@github-actions github-actions bot added the S: stale This issue is untriaged and hasn't seen any activity in at least six months. label Apr 2, 2024
@KaelWD KaelWD added T: bug Functionality that does not work as intended/expected C: VDialog VDialog and removed S: triage S: stale This issue is untriaged and hasn't seen any activity in at least six months. labels Apr 14, 2024
@KaelWD KaelWD self-assigned this Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VDialog VDialog T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

No branches or pull requests

2 participants