This repository has been archived by the owner on Dec 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(SearchBox): expose formRef (#3565)
<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. --> **Summary** This change is motivated from a very specific use case: I have a custom form input component which includes a `SearchBox`, so I my own `<form>` tag is wrapping the `<form>` that's within `SearchBox`. This leads to an unexpected form submission when pressing the <kbd>Enter</kbd> key in the search box text input. I've already tried `preventDefault` and `stopPropagation` in the `onSubmit` callback available for `SearchBox` but it seems the way React handles events makes this useless. Getting a `ref` for the form allowed me to stop the submit event by using `addEventListener` on the `ref.current` element. Since there's already an `inputRef` I think having a `formRef` won't hurt and would help others that may find themselves in a similar form nesting situation. **Result** A new `formRef` prop analog to current `inputRef` is added to `SearchBox`.
- Loading branch information
1 parent
894e261
commit 1c2f46d
Showing
4 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters