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 lint warning for gform_post_render hooks on AJAX enabled forms. #8

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

veryspry
Copy link
Collaborator

@veryspry veryspry commented Jan 28, 2025

Context

Slack: https://gravitywiz.slack.com/archives/C04PLMYN38W/p1736521082881049

Pertinent information:

we had a report of an issue with gform/postRender, the code was running an increasing number of times with each next,
previous, validation error redisplay that occurred

code chest is registering the snippets as form init scripts which adds them via gform_post_render, so each time that fires > it adds the listeners for the events from the code snippets again

Summary

Using gform_post_render, gform/postRender or gform/post_render on AJAX enabled forms can be problematic as the hook callbacks can be registered multiple times. (See above details)

This adds a lint warning to the JavaScript editor when these strings are detected.

image

…render`, `gform/postRender` and `gform/post_render`.
Copy link
Contributor

@claygriffiths claygriffiths left a comment

Choose a reason for hiding this comment

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

Nice work! Looks like this was tough to navigate.

@claygriffiths claygriffiths merged commit 04398df into main Jan 29, 2025
1 check passed
@claygriffiths claygriffiths deleted the matt/warning branch January 29, 2025 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants