Simplify didFocus logic in TextEditorComponent (#15309)

Prior to #15302, we wanted to make sure the component had rendered the
hidden input when receiving the focus event. To do so, we added some
workarounds for scenarios where the focus event was triggered before the
component had the chance to detect it was attached or visible.

After that pull-request, however, we always render the hidden input
independently of which events the component has observed, thus making
those workarounds not necessary anymore.

Please, note that we decided not to include this commit's changes in
beta, and want to let them bake for a full release cycle instead.

Co-authored-by: sadick254 <sadickjunior@gmail.com>
This commit is contained in:
Antonio Scandurra 2021-01-26 04:26:04 +01:00 committed by GitHub
parent 8d471a58e5
commit cfde3f2106
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1656,15 +1656,6 @@ module.exports = class TextEditorComponent {
// Called by TextEditorElement so that focus events can be handled before
// the element is attached to the DOM.
didFocus() {
// This element can be focused from a parent custom element's
// attachedCallback before *its* attachedCallback is fired. This protects
// against that case.
if (!this.attached) this.didAttach();
// The element can be focused before the intersection observer detects that
// it has been shown for the first time. If this element is being focused,
// it is necessarily visible, so we call `didShow` to ensure the hidden
// input is rendered before we try to shift focus to it.
if (!this.visible) this.didShow();
if (!this.focused) {