Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix case-sensitive path matching for the search box #3249

Merged
merged 4 commits into from
May 2, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions webapp/components/test-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,7 @@ class TestSearch extends WPTFlags(PolymerElement) {
let matches = Array.from(paths);
if (query) {
matches = matches
.filter(p => p.toLowerCase())
.filter(p => p.includes(query))
.filter(p => p.toLowerCase().includes(query))
LeonardYam marked this conversation as resolved.
Show resolved Hide resolved
.sort((p1, p2) => p1.indexOf(query) - p2.indexOf(query));
}
for (const match of matches.slice(0, 10 - datalist.children.length)) {
Expand Down Expand Up @@ -526,13 +525,15 @@ class TestSearch extends WPTFlags(PolymerElement) {
}

handleKeyDown(e) {
// Prevent tab key from working
LeonardYam marked this conversation as resolved.
Show resolved Hide resolved
if (e.keyCode === 9) {
e.preventDefault();
return false;
}
}

handleKeyUp(e) {
// Commit when enter key was pressed
if (e.keyCode === 13) {
this.commitQuery();
}
Expand All @@ -551,9 +552,9 @@ class TestSearch extends WPTFlags(PolymerElement) {
if (autocompleteSelection.getAttribute('atom')) {
return;
}
if (autocompleteSelection.value === path) {
if (autocompleteSelection.value.toLowerCase() === path) {
LeonardYam marked this conversation as resolved.
Show resolved Hide resolved
this.dispatchEvent(new CustomEvent('autocomplete', {
detail: {path: path},
detail: {path: autocompleteSelection.value},
}));
this.shadowRoot.querySelector('.query').blur();
}
Expand Down