Skip to content

Commit

Permalink
Cherry-pick 6d291b6. rdar://problem/113714342
Browse files Browse the repository at this point in the history
    Web Inspector: No search results
    https://bugs.webkit.org/show_bug.cgi?id=259843

    Reviewed by Devin Rousso.

    Web Inspector search is not working due to _inputFieldSearch(event) not
    being triggered.

    Replace incremental with throttle and replace "search" with "input".

    Import Throttler class to add _inputFieldInputThrottler function to handle throttler for "input" using fire function.
    Incorporate 250 ms delay.

    In _inputFieldKeyDown use findBannerRevealPreviousResult and findBannerRevealNextResult for shift and enter key presses
    replacing _searchBackwards and _searchForwards.

    Delete _inputFieldKeyUp.

    Delete _searchBackwards and _searchForwards in _inputFieldInput(event).

    * Source/WebInspectorUI/UserInterface/Views/FindBanner.js:
    (WI.FindBanner.prototype._inputFieldKeyDown):
    (WI.FindBanner.prototype._inputFieldInput):
    (WI.FindBanner.prototype._inputFieldKeyUp): Deleted.
    (WI.FindBanner.prototype._inputFieldSearch): Deleted.

    Canonical link: https://commits.webkit.org/266783@main

Identifier: 266246.380@safari-7617.1.4-branch
  • Loading branch information
francescorn authored and MyahCobbs committed Aug 14, 2023
1 parent b6652e0 commit 1a97755
Showing 1 changed file with 13 additions and 26 deletions.
39 changes: 13 additions & 26 deletions Source/WebInspectorUI/UserInterface/Views/FindBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ WI.FindBanner = class FindBanner extends WI.NavigationItem
this._inputField.type = "search";
this._inputField.placeholder = " "; // This is necessary for :placeholder-shown.
this._inputField.spellcheck = false;
this._inputField.incremental = true;
this._inputField.setAttribute("results", 5);
this._inputField.setAttribute("autosave", "inspector-search");
this._inputField.addEventListener("keydown", this._inputFieldKeyDown.bind(this), false);
this._inputField.addEventListener("keyup", this._inputFieldKeyUp.bind(this), false);
this._inputField.addEventListener("search", this._inputFieldSearch.bind(this), false);
this._inputFieldInputThrottler = new Throttler(this._inputFieldInput.bind(this), 250);
this._inputField.addEventListener("input", (event) => {
this._inputFieldInputThrottler.fire(event);
}, false);
this.element.appendChild(this._inputField);

this._previousResultButton = document.createElement("button");
Expand Down Expand Up @@ -86,8 +87,6 @@ WI.FindBanner = class FindBanner extends WI.NavigationItem
}

this._numberOfResults = null;
this._searchBackwards = false;
this._searchKeyPressed = false;
this._previousSearchValue = "";
}

Expand Down Expand Up @@ -229,34 +228,22 @@ WI.FindBanner = class FindBanner extends WI.NavigationItem

_inputFieldKeyDown(event)
{
if (event.keyIdentifier === "Shift")
this._searchBackwards = true;
else if (event.keyIdentifier === "Enter")
this._searchKeyPressed = true;
}

_inputFieldKeyUp(event)
{
if (event.keyIdentifier === "Shift")
this._searchBackwards = false;
else if (event.keyIdentifier === "Enter")
this._searchKeyPressed = false;
if (event.keyIdentifier === "Enter") {
if (this._numberOfResults > 0) {
if (event.shiftKey)
this._delegate?.findBannerRevealPreviousResult?.(this);
else
this._delegate?.findBannerRevealNextResult?.(this);
}
}
}

_inputFieldSearch(event)
_inputFieldInput(event)
{
if (this._inputField.value) {
if (this._previousSearchValue !== this.searchQuery) {
if (this._delegate && typeof this._delegate.findBannerPerformSearch === "function")
this._delegate.findBannerPerformSearch(this, this.searchQuery);
} else if (this._searchKeyPressed && this._numberOfResults > 0) {
if (this._searchBackwards) {
if (this._delegate && typeof this._delegate.findBannerRevealPreviousResult === "function")
this._delegate.findBannerRevealPreviousResult(this);
} else {
if (this._delegate && typeof this._delegate.findBannerRevealNextResult === "function")
this._delegate.findBannerRevealNextResult(this);
}
}
} else {
this.numberOfResults = null;
Expand Down

0 comments on commit 1a97755

Please sign in to comment.