Skip to content

Commit

Permalink
Search perf (#987)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLove-msft authored Sep 11, 2020
1 parent 72f1cf0 commit 17c41bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/dotnet/APIView/APIViewWeb/Client/src/reviews.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
$(() => {
const searchBox = $("#searchBox");

// make the search box the initial focused element so users can just start typing once page loads
searchBox.focus();

const context = $(".review-name") as any;
searchBox.keyup(function () {

// if already populated from navigating back, filter again
if (searchBox.val()) {
filter();
}

searchBox.on("input", function () {
setTimeout(filter, 300);
});

function filter() {
// highlight matching text using mark.js framework and hide rows that don't match
const searchText = (searchBox.val() as string).toUpperCase();
context.closest("tr").show().unmark();
Expand All @@ -17,5 +22,5 @@
}
});
}
});
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>

<div class="float-left pl-2">
<input type="text" class="form-control" id="searchBox" placeholder="Filter by review name">
<input type="text" class="form-control" id="searchBox" placeholder="Filter by review name" autofocus>
</div>

<div class="btn-group float-right">
Expand Down

0 comments on commit 17c41bf

Please sign in to comment.