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 handleSearch = (direction: SearchDirection) => {
|
||||||
const searchTerm = direction === SearchDirection.ToEnglish ? convertSearchBoxShorthand(searchBoxInput, conlang) : searchBoxInput;
|
// First convert any shorthand notation
|
||||||
if (searchTerm === "") {
|
let processedSearchTerm = direction === SearchDirection.ToEnglish ?
|
||||||
|
convertSearchBoxShorthand(searchBoxInput, conlang) :
|
||||||
|
searchBoxInput;
|
||||||
|
|
||||||
|
// Then normalize to lowercase
|
||||||
|
processedSearchTerm = processedSearchTerm.toLowerCase();
|
||||||
|
|
||||||
|
if (processedSearchTerm === "") {
|
||||||
setSearchResults(null);
|
setSearchResults(null);
|
||||||
setSearchTerm(null);
|
setSearchTerm(null);
|
||||||
setDirection(null);
|
setDirection(null);
|
||||||
} else {
|
} else {
|
||||||
searchEntry(searchTerm, conlang, direction, (json) => {
|
searchEntry(processedSearchTerm, conlang, direction, (json) => {
|
||||||
setSearchResults(json);
|
setSearchResults(json);
|
||||||
setSearchTerm(searchTerm);
|
setSearchTerm(processedSearchTerm);
|
||||||
setDirection(direction);
|
setDirection(direction);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -205,7 +212,7 @@ const App = (_props) => {
|
|||||||
onChange={ (evt) => {
|
onChange={ (evt) => {
|
||||||
setSearchBoxInput(evt.target.value);
|
setSearchBoxInput(evt.target.value);
|
||||||
}}
|
}}
|
||||||
placeholder="Enter search term"
|
placeholder="Enter search term (case-insensitive)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="searchControls">
|
<div className="searchControls">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user