Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Web Inspector: Incremental in FilterBar
https://bugs.webkit.org/show_bug.cgi?id=260043

Reviewed by Devin Rousso.

The filter bar was not working correctly due to "search" being removed.

Replace incremental with throttler. Delete incremental getter and setter.

Switch eventlistener to "input" instead of "search".

Rename "_handleFilterSearched" to "_handleFilterInput"

Delete unused "_handleFilterInputEvent"

* Source/WebInspectorUI/UserInterface/Views/FilterBar.js:
(WI.FilterBar.prototype.set filters):
(WI.FilterBar.prototype.addFilterBarButton):
(WI.FilterBar.prototype._handleFilterButtonToggled):
(WI.FilterBar.prototype._handleFilterInputEvent):
(WI.FilterBar.prototype.get incremental): Deleted.
(WI.FilterBar.prototype.set incremental): Deleted.
(WI.FilterBar.prototype._handleFilterChanged): Deleted.
(WI.FilterBar.prototype._handleFilterInputEvent): Deleted.

Canonical link: https://commits.webkit.org/266802@main
  • Loading branch information
francescorn authored and dcrousso committed Aug 11, 2023
1 parent 87c3092 commit 5df588e
Showing 1 changed file with 11 additions and 28 deletions.
39 changes: 11 additions & 28 deletions Source/WebInspectorUI/UserInterface/Views/FilterBar.js
Expand Up @@ -38,9 +38,13 @@ WI.FilterBar = class FilterBar extends WI.Object
this._inputField.type = "search";
this._inputField.placeholder = WI.UIString("Filter");
this._inputField.spellcheck = false;
this._inputField.incremental = true;
this._inputField.addEventListener("search", this._handleFilterChanged.bind(this));
this._inputField.addEventListener("input", this._handleFilterInputEvent.bind(this));
this._handleFilterInputThrottler = new Throttler(this._handleFilterInput.bind(this), 250);
this._inputField.addEventListener("input", (event) => {
if (this._inputField.value)
this._handleFilterInputThrottler.fire(event);
else
this._handleFilterInputThrottler.force(event);
});
this._element.appendChild(this._inputField);

this._filtersNavigationBar = new WI.NavigationBar;
Expand Down Expand Up @@ -73,16 +77,6 @@ WI.FilterBar = class FilterBar extends WI.Object
this._inputField.placeholder = text;
}

get incremental()
{
return this._inputField.incremental;
}

set incremental(incremental)
{
this._inputField.incremental = incremental;
}

get invalid()
{
return this._invalid;
Expand All @@ -106,7 +100,7 @@ WI.FilterBar = class FilterBar extends WI.Object
var oldTextValue = this._inputField.value;
this._inputField.value = filters.text || "";
if (oldTextValue !== this._inputField.value)
this._handleFilterChanged();
this._handleFilterInput();
}

focus()
Expand Down Expand Up @@ -149,7 +143,7 @@ WI.FilterBar = class FilterBar extends WI.Object
this.addFilterNavigationItem(filterBarButton);
if (filterBarButton.activated) {
this._filterFunctionsMap.set(filterBarButton.identifier, filterBarButton.filterFunction);
this._handleFilterChanged();
this._handleFilterInput();
}
}

Expand Down Expand Up @@ -188,28 +182,17 @@ WI.FilterBar = class FilterBar extends WI.Object
this._filterFunctionsMap.set(filterBarButton.identifier, filterBarButton.filterFunction);
else
this._filterFunctionsMap.delete(filterBarButton.identifier);
this._handleFilterChanged();
this._handleFilterInput();
}

_handleFilterChanged()
_handleFilterInput()
{
if (this.hasFilterChanged()) {
this._lastFilterValue = this.filters;
this.dispatchEventToListeners(WI.FilterBar.Event.FilterDidChange);
} else if (!this._inputField.value)
this._inputField.blur();
}

_handleFilterInputEvent(event)
{
// When not incremental we still want to detect if the field becomes empty.

if (this.incremental)
return;

if (!this._inputField.value)
this._handleFilterChanged();
}
};

WI.FilterBar.Event = {
Expand Down

0 comments on commit 5df588e

Please sign in to comment.