Commit 76ff8659 authored by Daniel Clark's avatar Daniel Clark Committed by Commit Bot

Fix timing issue where the color well is sometimes not focused initially

Since the ColorPicker's resize event listener is registered
asynchronously during another event callback, it is possible for it to
be registered too late to catch the resize event fired as a result of
the resizeWindow() call in initializeColorPicker(). The resize event
listener is responsible for setting the initial focus on the ColorWell,
so when it's missed focus remains outside of the popup.

This change moves the addEventListener to occur synchronously during
the ColorPicker constructor so that it will never attach too late.

There's no test because I couldn't get this to repro in a test
environment.  I've only seen it occur reliably in full Chrome (not
content_shell) with Narrator running, presumably because generating the
AX tree changes up the timing enough to expose the issue.

Change-Id: I752d86b3d9bf3c1462afd1705b8ce15aee28ef76
Bug: 1026183
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2148158Reviewed-by: default avatarIonel Popescu <iopopesc@microsoft.com>
Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Commit-Queue: Dan Clark <daniec@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#759868}
parent 263e5330
......@@ -437,6 +437,8 @@ class ColorPicker extends HTMLElement {
this.visualColorPicker_.addEventListener(
'visual-color-picker-initialized', this.initializeListeners_);
window.addEventListener('resize', this.onWindowResize_, {once: true});
}
initializeListeners_ = () => {
......@@ -448,8 +450,6 @@ class ColorPicker extends HTMLElement {
this.addEventListener('format-change', this.updateFocusableElements_);
document.documentElement.addEventListener('keydown', this.onKeyDown_);
window.addEventListener('resize', this.onWindowResize_, {once: true});
}
get selectedColor() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment