Normalize search input to lowercase for consistent results

This commit is contained in:
Greg Shuflin 2025-03-07 23:26:12 -08:00
parent de44275090
commit cc8920ef25

View File

@ -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">