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

Added pre-onSubmit callback to attach 'called' state #43

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Seligmann
Copy link
Contributor

Fixes #42

@Seligmann Seligmann requested a review from Xevion October 7, 2023 20:38
@vercel
Copy link

vercel bot commented Oct 7, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
portal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 7, 2023 8:39pm

@Seligmann
Copy link
Contributor Author

Just noticed that there's also #41 for this, so this fixes that as well.

@Xevion Xevion linked an issue Oct 7, 2023 that may be closed by this pull request
@Xevion Xevion added the bug Something isn't working label Oct 7, 2023
Copy link
Member

@Xevion Xevion left a comment

Choose a reason for hiding this comment

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

This still lets the person click the button a bunch, and it probably won't work if the submit button fails (network issue, error, anything other than "successful") - the button will be disabled forever.

I would recommend using React Hook Form to do this, as it's already using it.

react-hook-form/react-hook-form#834 (comment)

@Seligmann
Copy link
Contributor Author

This still lets the person click the button a bunch, and it probably won't work if the submit button fails (network issue, error, anything other than "successful") - the button will be disabled forever.

I would recommend using React Hook Form to do this, as it's already using it.

react-hook-form/react-hook-form#834 (comment)

While it does let the user click the button a bunch, I don't think that the fix fails if the other cases (e.g. network error) happen instead of a successful submission, as the 'called' state is set as soon as form is submitted. Do note that I did test this only for valid event creation.

I also actually did find that same thread that you've linked, but I couldn't get that implementation to work and tried this one out. I'll try the other implementation again, but I'm still not totally sure as to what the benefit is in comparison to this one.

On typing this out I now realize, and this might be what you're already saying, but there is still the issue of if a user submits a 'invalid' form, the 'called' state will be set as true, and it won't allow the user to correct the form for re-submission. This isn't too bad to fix with the current implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Event creation submit button can be spammed Multiple Events Created
2 participants