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

fix(VTextField): detect activeElement from shadowRoot #13053

Merged
merged 1 commit into from
Feb 23, 2021
Merged

fix(VTextField): detect activeElement from shadowRoot #13053

merged 1 commit into from
Feb 23, 2021

Conversation

matthieusieben
Copy link
Contributor

@matthieusieben matthieusieben commented Feb 4, 2021

Description

When an input element is inside a shadowDom, and is active (focused), the document.activeElement will not reference the input element but rather its shadowRoot. In order to properly detect what the activeElement is, we must use the proper root node for that element, as explained on MDN.

This PR:

  • Considers whether an element is attached to the DOM when computing tryAutofocus, and during the processing of onFocus event.
  • Correctly detects the focused element event if the component is inside a Shadow DOM (solving part of [Bug Report] Weird behaviour inside shadow DOM #7622)
  • Improves the quality of tests by enforcing focus/activeElement dependent tests to attach the mounted components to the DOM (read below for motivation)
  • Uses a shim to support IE11 (which does not have Shadow DOM)

Motivation and Context

This is part of the solution for #7622 ("Weird behaviour inside shadow DOM"). If fixes focus related issues when using Vuetify inside a shadow DOM.

It also improves the code base by attaching the element to the DOM for tests related to focus. This is important because Browsers (as well as jsdom used in tests) have a different behavior when trying to focus an element that is attached, and not (namely, when you focus an element that is not attached, is will not become the documet.activeElement).

How Has This Been Tested?

unit

Markup:

// Paste your FULL Playground.vue here

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Improvement/refactoring (non-breaking change that doesn't add any features but makes things better)

Checklist:

  • The PR title is no longer than 64 characters.
  • The PR is submitted to the correct branch (master for bug fixes and documentation updates, dev for new features and backwards compatible changes and next for non-backwards compatible changes).
  • My code follows the code style of this project.
  • I've added relevant changes to the documentation (applies to new features and breaking changes in core library)

@johnleider johnleider requested a review from KaelWD February 9, 2021 20:40
@johnleider johnleider added T: bug Functionality that does not work as intended/expected framework Issues and Feature Requests that have needs framework-wide. labels Feb 9, 2021
@johnleider johnleider added this to the v2.4.x milestone Feb 9, 2021
@KaelWD KaelWD force-pushed the master branch 12 times, most recently from ddbea7b to c7a93f7 Compare February 19, 2021 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
framework Issues and Feature Requests that have needs framework-wide. T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants