Skip to content

Commit

Permalink
Merge pull request #282 from ShwetKhatri2001/main
Browse files Browse the repository at this point in the history
Find from selection without space
  • Loading branch information
rockingrohit9639 authored Aug 5, 2021
2 parents 7b0604c + 5f975eb commit 8ba623f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/components/SearchBox/SearchBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function SearchBox({ fetchProjects })
const classes = useStyles();
const [{ query }, dispatch] = useDataLayerValues();
const [querySearch, setQuerySearch] = useState(query);
const [placeholder, setPlaceholder] = useState("e.g. reactjs (press space to focus)");
const [placeholder, setPlaceholder] = useState("e.g. reactjs (press space to focus then type and select)");
const searchOptions = [
"reactjs",
"javascript",
Expand All @@ -55,14 +55,12 @@ function SearchBox({ fetchProjects })

const handleSpaceKeyPress = useCallback(event =>
{

const { keyCode } = event;
if (keyCode === 32)
{
event.preventDefault();
document.getElementById('searchboxinput').focus();
setQuerySearch("");
setPlaceholder("e.g. reactjs");

}
}, []);

Expand Down Expand Up @@ -93,17 +91,16 @@ function SearchBox({ fetchProjects })
<form onSubmit={handleSubmit}>
<Autocomplete
id="searchboxinput"
noOptionsText={'try again and select option from dropdown'}
options={searchOptions}
value={querySearch}
onChange={(event, value) => setQuerySearch(value)}
freeSolo={true}
freeSolo={false}
classes={{ option: classes.option }}
renderInput={(params) => (
<div ref={params.InputProps.ref}>
<input
type="text"
value={querySearch}
onChange={(e) => setQuerySearch(e.target.value)}
placeholder={placeholder}
className={classes.input}
{...params.inputProps}
Expand Down

0 comments on commit 8ba623f

Please sign in to comment.