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