Commit 4de08c36 authored by Erik Luo's avatar Erik Luo Committed by Commit Bot

DevTools: do not increment on Arrow when showing SuggestBox

When SuggestBox is open, ArrowUp/Down should move vertically among
suggestions. Before, it might increment numerical values.

Bug: none
Change-Id: Ic0ede8ddca09818cd850be5bef06a8e685018dd0
Reviewed-on: https://chromium-review.googlesource.com/c/1258203Reviewed-by: default avatarJoel Einbinder <einbinder@chromium.org>
Commit-Queue: Erik Luo <luoe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596062}
parent 008d7ab2
...@@ -2107,7 +2107,7 @@ Elements.StylesSidebarPane.CSSPropertyPrompt = class extends UI.TextPrompt { ...@@ -2107,7 +2107,7 @@ Elements.StylesSidebarPane.CSSPropertyPrompt = class extends UI.TextPrompt {
case 'ArrowDown': case 'ArrowDown':
case 'PageUp': case 'PageUp':
case 'PageDown': case 'PageDown':
if (this._handleNameOrValueUpDown(event)) { if (!this.isSuggestBoxVisible() && this._handleNameOrValueUpDown(event)) {
event.preventDefault(); event.preventDefault();
return; return;
} }
......
...@@ -274,7 +274,7 @@ UI.TextPrompt = class extends Common.Object { ...@@ -274,7 +274,7 @@ UI.TextPrompt = class extends Common.Object {
*/ */
onKeyDown(event) { onKeyDown(event) {
let handled = false; let handled = false;
if (this._isSuggestBoxVisible() && this._suggestBox.keyPressed(event)) { if (this.isSuggestBoxVisible() && this._suggestBox.keyPressed(event)) {
event.consume(true); event.consume(true);
return; return;
} }
...@@ -299,7 +299,7 @@ UI.TextPrompt = class extends Common.Object { ...@@ -299,7 +299,7 @@ UI.TextPrompt = class extends Common.Object {
this.clearAutocomplete(); this.clearAutocomplete();
break; break;
case 'Escape': case 'Escape':
if (this._isSuggestBoxVisible()) { if (this.isSuggestBoxVisible()) {
this.clearAutocomplete(); this.clearAutocomplete();
handled = true; handled = true;
} }
...@@ -338,7 +338,7 @@ UI.TextPrompt = class extends Common.Object { ...@@ -338,7 +338,7 @@ UI.TextPrompt = class extends Common.Object {
*/ */
acceptAutoComplete() { acceptAutoComplete() {
let result = false; let result = false;
if (this._isSuggestBoxVisible()) if (this.isSuggestBoxVisible())
result = this._suggestBox.acceptSuggestion(); result = this._suggestBox.acceptSuggestion();
if (!result) if (!result)
result = this._acceptSuggestionInternal(); result = this._acceptSuggestionInternal();
...@@ -349,7 +349,7 @@ UI.TextPrompt = class extends Common.Object { ...@@ -349,7 +349,7 @@ UI.TextPrompt = class extends Common.Object {
clearAutocomplete() { clearAutocomplete() {
const beforeText = this.textWithCurrentSuggestion(); const beforeText = this.textWithCurrentSuggestion();
if (this._isSuggestBoxVisible()) if (this.isSuggestBoxVisible())
this._suggestBox.hide(); this._suggestBox.hide();
this._clearAutocompleteTimeout(); this._clearAutocompleteTimeout();
this._queryRange = null; this._queryRange = null;
...@@ -382,7 +382,7 @@ UI.TextPrompt = class extends Common.Object { ...@@ -382,7 +382,7 @@ UI.TextPrompt = class extends Common.Object {
* @param {boolean=} force * @param {boolean=} force
*/ */
autoCompleteSoon(force) { autoCompleteSoon(force) {
const immediately = this._isSuggestBoxVisible() || force; const immediately = this.isSuggestBoxVisible() || force;
if (!this._completeTimeout) { if (!this._completeTimeout) {
this._completeTimeout = this._completeTimeout =
setTimeout(this.complete.bind(this, force), immediately ? 0 : this._autocompletionTimeout); setTimeout(this.complete.bind(this, force), immediately ? 0 : this._autocompletionTimeout);
...@@ -401,7 +401,7 @@ UI.TextPrompt = class extends Common.Object { ...@@ -401,7 +401,7 @@ UI.TextPrompt = class extends Common.Object {
let shouldExit; let shouldExit;
if (!force && !this._isCaretAtEndOfPrompt() && !this._isSuggestBoxVisible()) if (!force && !this._isCaretAtEndOfPrompt() && !this.isSuggestBoxVisible())
shouldExit = true; shouldExit = true;
else if (!selection.isCollapsed) else if (!selection.isCollapsed)
shouldExit = true; shouldExit = true;
...@@ -565,9 +565,10 @@ UI.TextPrompt = class extends Common.Object { ...@@ -565,9 +565,10 @@ UI.TextPrompt = class extends Common.Object {
} }
/** /**
* @protected
* @return {boolean} * @return {boolean}
*/ */
_isSuggestBoxVisible() { isSuggestBoxVisible() {
return this._suggestBox && this._suggestBox.visible(); return this._suggestBox && this._suggestBox.visible();
} }
......
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