Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear search input on submit #24

Open
Ishaan-11 opened this issue Jan 7, 2021 · 5 comments
Open

Clear search input on submit #24

Ishaan-11 opened this issue Jan 7, 2021 · 5 comments

Comments

@Ishaan-11
Copy link

e.currentTarget.reset();

If this line is used for clearing the search input then it is not being cleared.
I suggest adding setSearchEntry(""); after handleSubmit call
onSubmit={e => handleSubmit(e, history, searchEntry)}

@kushalShukla-web
Copy link

ishaan can you pls tell me how this handlechange is working i dont
understand it.

@kushalShukla-web
Copy link

sorry ishaan but i can't see my committed code in ur main code. im new in opensource.

@Ishaan-11
Copy link
Author

Hi @kushalShukla-web , this repo belongs to @Yog9 , so for your changes to reflect you need create Pull Request on the repo of @Yog9 .
I would recommend this video for open source guidance.
I hope this helps you.

@Ishaan-11 Ishaan-11 reopened this Sep 28, 2021
@SOMKUVAR
Copy link

SOMKUVAR commented Apr 26, 2023

I want to work on this issue.
Please assign me.

@Dhruva21
Copy link

Dhruva21 commented Jul 29, 2023

Hi @Yog9 ,
I have a question regarding the handle submit function which is written in App.js. We initialized the searchEntry state in Form.js and just sending the updated searchEntry to handle submit function. But we cannot update the state and clear the search bar. But instead we can control handle submit function in Form.js and update the searchEntry state.
My fix: I removed the handleSubmit prop in

and removed the handle submit function from App.js and handle that in Form.js. Is this the correct fix? Or anything else is required, please let me know.
Code change in App.js:

**Code change in Form.js:** const handleSubmit = (e, history, searchEntry) => { e.preventDefault(); e.currentTarget.reset(); let url = `/search/${searchEntry}`; history.push(url); **setSearchEntry('')** };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants