Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

feat(onSubmit): introduce onSubmit option #24

Merged
merged 1 commit into from
Feb 11, 2020
Merged

Conversation

francoischalifour
Copy link
Owner

Description

This PR introduces the onSubmit option. This prop is called when the submit form event is triggered (not when an item is selected – subject to another PR).

Use case

The submit form event is triggered when the user hits Enter without any item selected.

In an InstantSearch context, it's the default behavior of the search box, where we would call refine. Note that with an InstantSearch implementation, we would also call refine when calling onSelect.

@@ -46,7 +46,16 @@ export function getPropGetters<TItem>({
onSubmit: event => {
event.preventDefault();
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if preventing the default behavior should be part of the default onSubmit implementation. Are there any cases where users would like to use the default submit form event?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any use case where user would want to keep default submit event.

@francoischalifour francoischalifour merged commit ca0891c into next Feb 11, 2020
@francoischalifour francoischalifour deleted the feat/onSubmit branch February 11, 2020 15:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants