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

Feature/nonprofit form error message #514

Merged
merged 15 commits into from
Feb 13, 2024

Conversation

JosueMagnus12
Copy link
Collaborator

Context

Users were having problems sending a message on the "add a nonprofit" when submitting the form. Basically no error messages were displayed and the field were wiped.

What changed

  • Disabled Turbo for message form
  • Removed reload meta tag
  • Added model validations
  • Added new flash messages partial

How to test it

  1. Go to "Add a nonprofit" page
  2. Try to submit the form without checking the captcha, filling all required inputs, etc.

References

ClickUp ticket

Comment on lines +1 to +11
import { Controller } from '@hotwired/stimulus'

export default class extends Controller {
static values = { targetUrls: Array }

disableTurboForTargetUrls(event) {
if (this.targetUrlsValue.includes(event.detail.url)) {
event.preventDefault();
}
}
}
Copy link
Collaborator Author

@JosueMagnus12 JosueMagnus12 Feb 13, 2024

Choose a reason for hiding this comment

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

Even if we disable turbo in the message forms with data-turbo="false", the RECaptcha is still failing. Adding the data-turbo-track="reload" meta tag doesn't help either, because it wipes the form error messages.

The only viable solution I found is to disable turbo before the browser issues a new request to fetch these forms. This is great because it can work across the entire app and we don't have to add data-turbo="false" to every link_to that links to these forms.

Comment on lines +12 to +16

# recaptcha gem doesn't work well with Turbo
def turbo_disabled_urls
[new_nonprofit_request_url, new_contact_message_url]
end
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just add the urls for which you want to disable Turbo.

@JosueMagnus12 JosueMagnus12 merged commit 676812f into main Feb 13, 2024
2 checks passed
@JosueMagnus12 JosueMagnus12 deleted the feature/nonprofit-form-error-message branch February 13, 2024 21:43
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

Successfully merging this pull request may close these issues.

2 participants