Commit 09ad7587 authored by lushnikov's avatar lushnikov Committed by Commit bot

DevTools: convert UI.ComboBoxFilterUI to use vanilla <select> element

Currently, the UI.ComboBoxFilterUI uses UI.ToolbarComboBox for the select
element. However, the component should be used only as a toolbar child,
since the toolbar has a bunch of CSS for the component.

This patch migrates UI.ComboBoxFilterUI from UI.ToolbarComboBox to a
simple <select>

BUG=674463
R=dgozman

Review-Url: https://codereview.chromium.org/2577953004
Cr-Commit-Position: refs/heads/master@{#438998}
parent 4296cd33
...@@ -491,16 +491,18 @@ UI.ComboBoxFilterUI = class extends Common.Object { ...@@ -491,16 +491,18 @@ UI.ComboBoxFilterUI = class extends Common.Object {
this._filterElement.className = 'filter-combobox-filter'; this._filterElement.className = 'filter-combobox-filter';
this._options = options; this._options = options;
this._filterComboBox = new UI.ToolbarComboBox(this._filterChanged.bind(this)); this._filterComboBox = createElementWithClass('select', 'chrome-select');
this._filterComboBox.addEventListener('input', this._filterChanged.bind(this), false);
for (var i = 0; i < options.length; ++i) { for (var i = 0; i < options.length; ++i) {
var filterOption = options[i]; var filterOption = options[i];
var option = createElement('option'); var option = createElement('option');
option.text = filterOption.label; option.text = filterOption.label;
option.title = filterOption.title; option.title = filterOption.title;
this._filterComboBox.addOption(option); this._filterComboBox.appendChild(option);
this._filterComboBox.element.title = this._filterComboBox.selectedOption().title;
} }
this._filterElement.appendChild(this._filterComboBox.element); if (options.length)
this._filterComboBox.title = options[0].title;
this._filterElement.appendChild(this._filterComboBox);
} }
/** /**
...@@ -508,7 +510,7 @@ UI.ComboBoxFilterUI = class extends Common.Object { ...@@ -508,7 +510,7 @@ UI.ComboBoxFilterUI = class extends Common.Object {
* @return {boolean} * @return {boolean}
*/ */
isActive() { isActive() {
return this._filterComboBox.selectedIndex() !== 0; return this._filterComboBox.selectedIndex !== 0;
} }
/** /**
...@@ -523,7 +525,7 @@ UI.ComboBoxFilterUI = class extends Common.Object { ...@@ -523,7 +525,7 @@ UI.ComboBoxFilterUI = class extends Common.Object {
* @return {*} * @return {*}
*/ */
value() { value() {
var option = this._options[this._filterComboBox.selectedIndex()]; var option = this._options[this._filterComboBox.selectedIndex];
return option.value; return option.value;
} }
...@@ -531,22 +533,22 @@ UI.ComboBoxFilterUI = class extends Common.Object { ...@@ -531,22 +533,22 @@ UI.ComboBoxFilterUI = class extends Common.Object {
* @param {number} index * @param {number} index
*/ */
setSelectedIndex(index) { setSelectedIndex(index) {
this._filterComboBox.setSelectedIndex(index); this._filterComboBox.selectedIndex = index;
} }
/** /**
* @return {number} * @return {number}
*/ */
selectedIndex(index) { selectedIndex(index) {
return this._filterComboBox.selectedIndex(); return this._filterComboBox.selectedIndex;
} }
/** /**
* @param {!Event} event * @param {!Event} event
*/ */
_filterChanged(event) { _filterChanged(event) {
var option = this._options[this._filterComboBox.selectedIndex()]; var option = this._options[this._filterComboBox.selectedIndex];
this._filterComboBox.element.title = option.title; this._filterComboBox.title = option.title;
this.dispatchEventToListeners(UI.FilterUI.Events.FilterChanged, null); this.dispatchEventToListeners(UI.FilterUI.Events.FilterChanged, null);
} }
}; };
......
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