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

fix(donation-form): Don't clear form fields via JS if no Give form is present on the page #3093

Closed
mathetos opened this issue Apr 24, 2018 · 2 comments

Comments

@mathetos
Copy link
Member

User Story

As a Give user, I want to be able to navigate through my site without any JS errors.

Current Behavior

As reported here:
https://wordpress.org/support/topic/js-errors-when-you-hit-the-back-button/#post-10211556

The Give plugin includes some JavaScript that is meant to clear a donation form if you fill out a form and then use the “Back” button in your browser to go back to a page with the form. That’s great, but the problem is that it tries to clear the data on every page, not just on pages with a donation form, so if you go back to a page without a form, you get an error: TypeError: e(...).find(...)[0] is undefined
The problem is in assets/js/frontend/give.js, line 108.

Expected Behavior

I expect to be able to navigate back on pages that do NOT have a Give form and not encounter a JS error on them.

Possible Solution

Detect if the page has a Give form and only target the Give form pages if they are present. Optionally, only enqueue our Give JS on pages where a Give form exists.

Steps to Reproduce

  1. Go to a page on your site that does NOT have a Give form.
  2. Navigate to another page on your site that also does not have A Give form.
  3. Hit your browsers back button.
  4. Confirm the JS error described above.

Related

@ravinderk
Copy link
Collaborator

@mathetos This issue already has been resolved. Please confirm: #3019

@mathetos
Copy link
Member Author

Thanks @ravinderk apologies I didn't search existing issues beforehand. Great work!

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

2 participants