Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui_lazy/FilteredListWidget.js

Issue 2469153003: DevTools: Remove ghost text from FilteredListWidget (Closed)
Patch Set: Exit test on rejected promise Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/ui_lazy/FilteredListWidget.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui_lazy/FilteredListWidget.js b/third_party/WebKit/Source/devtools/front_end/ui_lazy/FilteredListWidget.js
index f15fb130afff5e959c322289842ce96ff3b15ef2..f68168b948c4f1e872b83d4eeb9a998a8fd4bee6 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui_lazy/FilteredListWidget.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui_lazy/FilteredListWidget.js
@@ -17,7 +17,7 @@ WebInspector.FilteredListWidget = class extends WebInspector.VBox {
this._renderAsTwoRows = delegate.renderAsTwoRows();
this.contentElement.classList.add('filtered-list-widget');
- this.contentElement.addEventListener('keydown', this._onKeyDown.bind(this), false);
+ this.contentElement.addEventListener('keydown', this._onKeyDown.bind(this), true);
if (delegate.renderMonospace())
this.contentElement.classList.add('monospace');
this.registerRequiredCSS('ui_lazy/filteredListWidget.css');
@@ -26,9 +26,8 @@ WebInspector.FilteredListWidget = class extends WebInspector.VBox {
this._promptElement.setAttribute('spellcheck', 'false');
this._promptElement.setAttribute('contenteditable', 'plaintext-only');
this._prompt = new WebInspector.TextPrompt();
- this._prompt.initialize(this._autocomplete.bind(this));
+ this._prompt.initialize(() => undefined);
this._prompt.renderAsBlock();
- this._prompt.addEventListener(WebInspector.TextPrompt.Events.ItemAccepted, this._onAutocompleted, this);
var promptProxy = this._prompt.attach(this._promptElement);
promptProxy.addEventListener('input', this._onInput.bind(this), false);
promptProxy.classList.add('filtered-list-widget-prompt-element');
@@ -47,7 +46,6 @@ WebInspector.FilteredListWidget = class extends WebInspector.VBox {
this._itemsLoaded();
this._updateShowMatchingItems();
this._viewportControl.refresh();
- this._prompt.autoCompleteSoon(true);
/** @typedef {!Array.<!Element>} */
this._elements = [];
@@ -147,19 +145,14 @@ WebInspector.FilteredListWidget = class extends WebInspector.VBox {
this._scheduleFilter();
}
- /**
- * @param {!Element} proxyElement
- * @param {!Range} wordRange
- * @param {boolean} force
- * @param {function(!Array.<string>, number=)} completionsReadyCallback
- */
- _autocomplete(proxyElement, wordRange, force, completionsReadyCallback) {
- var completions = wordRange.startOffset === 0 ? [this._delegate.autocomplete(wordRange.toString())] : [];
- completionsReadyCallback.call(null, completions);
- this._autocompletedForTests();
+ _tabKeyPressed() {
+ var userEnteredText = this._prompt.text();
+ var completion = this._delegate.autocomplete(userEnteredText);
+ this._prompt.setText(completion);
+ this._prompt.setDOMSelection(userEnteredText.length, completion.length);
}
- _autocompletedForTests() {
+ _itemsFilteredForTest() {
// Sniffed in tests.
}
@@ -248,6 +241,7 @@ WebInspector.FilteredListWidget = class extends WebInspector.VBox {
if (!query)
this._selectedIndexInFiltered = 0;
this._updateSelection(this._selectedIndexInFiltered, false);
+ this._itemsFilteredForTest();
}
}
@@ -258,11 +252,6 @@ WebInspector.FilteredListWidget = class extends WebInspector.VBox {
return this._delegate.shouldShowMatchingItems(this._value());
}
- _onAutocompleted() {
- this._prompt.autoCompleteSoon(true);
- this._onInput();
- }
-
_onInput() {
this._updateShowMatchingItems();
this._scheduleFilter();
@@ -309,6 +298,9 @@ WebInspector.FilteredListWidget = class extends WebInspector.VBox {
case WebInspector.KeyboardShortcut.Keys.Enter.code:
this._onEnter(event);
break;
+ case WebInspector.KeyboardShortcut.Keys.Tab.code:
+ this._tabKeyPressed();
+ break;
default:
}
}
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/TextPrompt.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698