Repository navigation
Keep the Gravity Forms recorder working after an AJAX page change - #2217
Conversation
Gravity Forms replaces a page's markup on every AJAX page change or failed submit. The recorder kept pointing at the replaced container, file input and button, and Uppy had bound its dashboard trigger once to the old button, so Start Recording opened nothing on the new page. On every gform_post_render, an uploader whose markup left the page now finds the new container by its id, reads the input and button from it, binds the new button once and shows the recording it holds again.
🔍 WordPress Plugin Check Report
📊 Report
|
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
620 |
WordPress.DB.SlowDBQuery.slow_db_query_meta_key | Detected usage of meta_key, possible slow query. |
📁 readme.txt (2 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
mismatched_plugin_name | Plugin name "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" is different from the name declared in plugin header "GoDAM". |
0 |
trademarked_term | The plugin name includes a restricted term. Your chosen plugin name - "GoDAM - Organize WordPress Media Library & File Manager with Unlimited Folders for Images, Videos & more" - contains the restricted term "wordpress" which cannot be used at all in your plugin name. |
📁 inc/classes/class-video-sitemap-core-provider.php (1 warning)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
73 |
WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound | Hook names invoked by a theme/plugin should start with the theme/plugin prefix. Found: "wp_sitemaps_index_entry". |
📁 assets/build/css/main.css (1 warning)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedStylesScope | This style is being loaded in all contexts. |
📁 assets/src/libs/analytics.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/10/20/demo-post-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-page-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle analytics-library) is loaded in the footer. Consider a defer or async script loading strategy instead. |
📁 assets/build/js/main.min.js (5 warnings)
| 📍 Line | 🔖 Check | 💬 Message |
|---|---|---|
0 |
EnqueuedScriptsScope | This script is being loaded in all frontend contexts. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880 (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/2026/10/20/demo-post-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-page-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
0 |
NonBlockingScripts.NoStrategy | This script on http://localhost:8880/demo-attachment-post/ (with handle rtgodam-script) is loaded in the footer. Consider a defer or async script loading strategy instead. |
🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check
…ax-page-change # Conflicts: # languages/godam.pot
# Conflicts: # languages/godam.pot
Code reviewVerdict: LGTM — solid, well-tested fix with a clean refactor. The root cause (stale A couple of points, one worth a look before merge: 1. Fields that first appear via AJAX get no instance (robustness) —
|
|
Thanks Kuldip.
Minor: agreed, |
Fixes #2222
Review packet
In one line: On a Gravity Forms form with AJAX turned on, the GoDAM Record field now keeps working after the visitor changes page or a submit fails, so Start Recording opens the recorder again. Fixes #2222. Related to #2159 (same form flow, found while retesting it).
1. Criteria and proof
ajax validate, 10 checks, on Gravity Forms 3.1.2 and on 2.7.7.1 (the older iframe AJAX). Log only, not in the videopostback plainandpostback validate, all checks pass2. Before and after
Left pane: a form with AJAX on (the setup that failed). Right pane: the same form with AJAX off, as a control. Both panes get the same visitor actions. Each step has a check, so a red step is a real failure.
Before (develop, 2.4.0): on the AJAX form, Start Recording opens nothing after Next; the control opens and records
After (this branch): the full flow on both forms, 8 steps, all checked
3. Tests
assets/src/js/godam-recorder/index.test.js, 11 tests. They replace a page's markup the way Gravity Forms does, firegform_post_render, and assert: the new button opens the dashboard exactly once (also with a different button id, with the event fired three times, and across several page changes); the held recording is shown again; it is not sent again when Gravity Forms holds a copy and is put on the new file input when it does not; removing it after the page change drops Gravity Forms' saved copy; nothing happens while the markup is still on the page; a field that is not on the page yet is picked up when it appears. The Uppy stand-in binds its dashboard trigger once at install, as the real one does.index.jsput back, 8 of the 11 fail, for example "opens the dashboard from the new button after a page change" withExpected number of calls: 1,Received number of calls: 0. With the fix all 11 pass.4. Risk flags
No risk flags fired on #2217. Nothing in the diff touched the watched areas.
5. Independent review
A fresh reviewer saw only the task and the diff. It found nothing it could confirm. Two low-confidence points:
gform_uploaded_filesinput only for multi-file upload fields, so on a form whose only upload fields are Record fields an AJAX page change might throw inside Gravity Forms beforegform_post_renderfires6. Not verified
7. Scope
The fix is in
assets/src/js/godam-recorder/index.jswith its new test.languages/godam.potchanges by three source line references (the recorder's lines moved), regenerated with the repo's own build andmake-pot, because the POT check requires it. No PHP, no changelog line, no version bump.What was wrong
When Gravity Forms changes page or fails a submit over AJAX it replaces that page's markup and fires
gform_post_render. The recorder kept pointing at the old container, file input and button, and Uppy had bound its dashboard trigger once, to the old button. The old handler also returned unless the form had a validation error, so on a page change nothing was re-bound and Start Recording did nothing, without any error. The server prints the trigger button's id withwp_unique_id(), so it can differ on every render.What changed
On every
gform_post_render, an uploader whose container left the page finds the new container by its id (stable between renders), reads the file input and button from it, adds one click listener to the new button, and shows the recording it already holds again. Nothing changes while the markup is still on the page (first render, a non-AJAX submit, a page the response did not replace). The non-AJAX path and the other form plugins go through the same lookup as before.