Skip to content

Commit fe53225

Browse files
committed
Fix entered text submission
1 parent b8909cc commit fe53225

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

client/src/components/SearchBar/SearchBar.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,16 @@ export default function SearchBar2({ postSearchHandler, query }) {
3737
};
3838

3939
const onEnterButton = (event) => {
40-
// console.log(`onEnterButton: ${q}`);
41-
// if (event.keyCode === 13) {
42-
// console.log(`Enter key pressed ${q}`);
43-
// search(q);
44-
// }
40+
console.log(`onEnterButton: ${q}`);
41+
// if enter key is pressed
42+
if (event.key === 'Enter') {
43+
search(q);
44+
}
4545
};
4646

4747
return (
4848
<div
4949
className="input-group"
50-
onKeyDown={onEnterButton}
5150
style={{ width: '95%', display: 'flex', justifyContent: 'center', alignItems: 'center', margin: '0 auto' }}
5251
>
5352
<Box sx={{ display: 'flex', alignItems: 'center', width: '75%', minWidth: '390px' }}>
@@ -76,7 +75,10 @@ export default function SearchBar2({ postSearchHandler, query }) {
7675
)}
7776
/>
7877
<div className="input-group-btn" style={{ marginLeft: '10px' }}>
79-
<Button variant="contained" color="primary" >
78+
<Button variant="contained" color="primary" onClick={() => {
79+
console.log(`search button: ${q}`);
80+
search(q)}
81+
}>
8082
Search
8183
</Button>
8284
</div>

0 commit comments

Comments
 (0)