-
-
Notifications
You must be signed in to change notification settings - Fork 255
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
Feature: ability to see search result in index page #3134
Feature: ability to see search result in index page #3134
Conversation
// This line fixes a bug where the search box would be duplicated on back navigation. | ||
this.autocompleteTarget.innerHTML = '' | ||
|
||
const { destroy } = autocomplete({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
document.body.classList.remove('aa-Detached') | ||
} | ||
|
||
searchUrl(query) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
} | ||
} | ||
|
||
addSource(resourceName, data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function addSource
has 73 lines of code (exceeds 25 allowed). Consider refactoring.
header() { | ||
return `${data.header.toUpperCase()} ${data.help}` | ||
}, | ||
item({ item, createElement }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function item
has 54 lines of code (exceeds 25 allowed). Consider refactoring.
} | ||
} | ||
|
||
addSource(resourceName, data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
Code Climate has analyzed commit 642358f and detected 0 issues on this pull request. View more on Code Climate. |
} | ||
} | ||
|
||
handleOnSelect({ item }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
// params.global = true | ||
// } | ||
|
||
if (this.isBelongsToSearch || this.isHasManySearch) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
} | ||
} | ||
|
||
addSource(resourceName, data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function addSource
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
return this.dataset.searchResource === 'global' | ||
} | ||
|
||
connect() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function connect
has 38 lines of code (exceeds 25 allowed). Consider refactoring.
return params | ||
} | ||
|
||
addReflectionParams(params) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
}, | ||
getSources: ({ query }) => { | ||
document.body.classList.add('search-loading') | ||
const endpoint = that.searchUrl(query) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first look, seems like potential XSS. Should query
be sanitized?
const sanitizedQuery = encodeURIComponent(query);
const endpoint = that.searchUrl(sanitizedQuery);
'clearButton', | ||
] | ||
|
||
debouncedFetch = debouncePromise(fetch, this.searchDebounce) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this.searchDebounce
return link to the function, instead of the result of searchDebounce()
?
I'd advise adding tests
// form.requestSubmit() | ||
// Retrieve params via url.search, passed into constructor | ||
const url = new URL(window.location) | ||
console.log(url.searchParams.toString(), event.target.value) |
Check failure
Code scanning / CodeQL
Use of externally-controlled format string
c4b25cc
to
642358f
Compare
This PR has been marked as stale because there was no activity for the past 15 days. |
Closing this because there was no activity for the past 15 days. Feel free to reopen if new information pops up ✌️ |
Description
Fixes #2842
Checklist:
Screenshots & recording
Manual review steps
Manual reviewer: please leave a comment with output from the test if that's the case.