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

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

Issue 2458383003: DevTools: Remove ghost text from FilteredListWidget (Closed)
Patch Set: 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
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 d1e5bc9b2a668832100af07802cb28b8b31d2061..828013bef20b12d7f35e079f8e1d85712283e8a7 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 = function(delegate)
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 = function(delegate)
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 = function(delegate)
this._itemsLoaded();
this._updateShowMatchingItems();
this._viewportControl.refresh();
- this._prompt.autoCompleteSoon(true);
/** @typedef {!Array.<!Element>} */
this._elements = [];
@@ -149,24 +147,18 @@ WebInspector.FilteredListWidget.prototype = {
setQuery: function(query)
{
this._prompt.setText(query);
- this._prompt.autoCompleteSoon(true);
this._scheduleFilter();
},
- /**
- * @param {!Element} proxyElement
- * @param {!Range} wordRange
- * @param {boolean} force
- * @param {function(!Array.<string>, number=)} completionsReadyCallback
- */
- _autocomplete: function(proxyElement, wordRange, force, completionsReadyCallback)
+ _autocomplete: function()
lushnikov 2016/11/01 22:35:32 "We can change this to _tabKeyPressed"(Joel)
{
- var completions = wordRange.startOffset === 0 ? [this._delegate.autocomplete(wordRange.toString())] : [];
- completionsReadyCallback.call(null, completions);
- this._autocompletedForTests();
+ var userEnteredText = this._prompt.text();
+ var completion = this._delegate.autocomplete(userEnteredText);
+ this._prompt.setText(completion);
+ this._prompt.setDOMSelection(userEnteredText.length, completion.length);
},
- _autocompletedForTests: function()
+ _itemsFilteredForTest: function()
{
// Sniffed in tests.
},
@@ -258,6 +250,7 @@ WebInspector.FilteredListWidget.prototype = {
if (!query)
this._selectedIndexInFiltered = 0;
this._updateSelection(this._selectedIndexInFiltered, false);
+ this._itemsFilteredForTest();
}
},
@@ -269,12 +262,6 @@ WebInspector.FilteredListWidget.prototype = {
return this._delegate.shouldShowMatchingItems(this._value());
},
- _onAutocompleted: function()
- {
- this._prompt.autoCompleteSoon(true);
- this._onInput();
- },
-
_onInput: function()
{
this._updateShowMatchingItems();
@@ -325,6 +312,9 @@ WebInspector.FilteredListWidget.prototype = {
case WebInspector.KeyboardShortcut.Keys.Enter.code:
this._onEnter(event);
break;
+ case WebInspector.KeyboardShortcut.Keys.Tab.code:
+ this._autocomplete();
+ break;
default:
}
},

Powered by Google App Engine
This is Rietveld 408576698