Normalize search input to lowercase for consistent results
This commit is contained in:
parent
de44275090
commit
cc8920ef25
17
src/App.tsx
17
src/App.tsx
@ -143,15 +143,22 @@ const App = (_props) => {
|
||||
};
|
||||
|
||||
const handleSearch = (direction: SearchDirection) => {
|
||||
const searchTerm = direction === SearchDirection.ToEnglish ? convertSearchBoxShorthand(searchBoxInput, conlang) : searchBoxInput;
|
||||
if (searchTerm === "") {
|
||||
// First convert any shorthand notation
|
||||
let processedSearchTerm = direction === SearchDirection.ToEnglish ?
|
||||
convertSearchBoxShorthand(searchBoxInput, conlang) :
|
||||
searchBoxInput;
|
||||
|
||||
// Then normalize to lowercase
|
||||
processedSearchTerm = processedSearchTerm.toLowerCase();
|
||||
|
||||
if (processedSearchTerm === "") {
|
||||
setSearchResults(null);
|
||||
setSearchTerm(null);
|
||||
setDirection(null);
|
||||
} else {
|
||||
searchEntry(searchTerm, conlang, direction, (json) => {
|
||||
searchEntry(processedSearchTerm, conlang, direction, (json) => {
|
||||
setSearchResults(json);
|
||||
setSearchTerm(searchTerm);
|
||||
setSearchTerm(processedSearchTerm);
|
||||
setDirection(direction);
|
||||
});
|
||||
}
|
||||
@ -205,7 +212,7 @@ const App = (_props) => {
|
||||
onChange={ (evt) => {
|
||||
setSearchBoxInput(evt.target.value);
|
||||
}}
|
||||
placeholder="Enter search term"
|
||||
placeholder="Enter search term (case-insensitive)"
|
||||
/>
|
||||
</div>
|
||||
<div className="searchControls">
|
||||
|
Loading…
x
Reference in New Issue
Block a user