Repository navigation
Refresh source fields for Lookup and Dynamic choice sorting - #3608
Crabcyborg wants to merge 9 commits into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| PHP | Dec 1, 2026 7:33p.m. | Review ↗ | |
| JavaScript | Dec 1, 2026 7:33p.m. | Review ↗ |
Important
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
There was a problem hiding this comment.
Approving: the builder JS does what it says, with three small non-blocking notes below.
What I ran (preview env, Lite on this PR + Pro companion #6885, a Lookup and a Dynamic field on seeded forms):
- Lookup: changing the source form from SrcA to SrcB replaced Order by with SrcB's fields and reset it to "Option label". Setting the form to blank cleared it down to "Option label".
- Dynamic: changing the source form replaced Order by with the new form's fields. Switching the source to Taxonomy cleared it.
- The initial server-rendered Order by list matched the source field list on both field types.
- Not tested: the actual front-end sort order (that is the Pro half), and I did not rebuild
formidable_admin.jsto confirm it matches the source. Psalm is red, but it fails the same way onmasterand this diff has no PHP.
Non-blocking notes (nothing posted inline, all in js/src/admin/admin.js):
getTaxOrFieldSelectionsuccess callback:$selectedFields.get( 0 ).querySelector( 'select' )throws if the container is gone when the response lands. The old.html().show()was a no-op on an empty set. Useconst container = $selectedFields.get( 0 ); const sourceSelect = container ? container.querySelector( 'select' ) : null;.toggleFormTax,val === 'form'branch: it empties the source field select but does not reset Order by, so the old form's fields stay listed. AddupdateOrderFieldSelection( id, [] );next toempty( $showFields );.- After a form change, Order by is copied from the source select, which
frm_get_options_for_get_values_fieldtruncates to 30 characters. The initial server render inorder.phpdoes not truncate. Long field names read differently before and after a change. Cosmetic.
This PR is still a draft and depends on formidable-pro#6885 for the frm_order_field_<id> element. Without it updateOrderFieldSelection returns early, which is safe.
# Conflicts: # js/formidable_admin.js
…-sort Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Skip the source select lookup when the field selection container is gone before the AJAX response lands. Clear the Order by options when a Dynamic field switches its source back to a form. Rebuild the builder bundle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed franky's review notes in df9f8a8:
Also merged the latest master (clean) and rebuilt |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3608 +/- ##
============================================
+ Coverage 48.87% 48.96% +0.09%
- Complexity 14432 14465 +33
============================================
Files 240 241 +1
Lines 48416 48481 +65
============================================
+ Hits 23664 23740 +76
+ Misses 24752 24741 -11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Approve. The two code notes from my last review are fixed at this head, and the third is correctly left to the Pro PR.
Checked at df9f8a8 (preview env, Lite on this PR plus Pro #6885 at 49a1dbd, seeded forms SrcA / SrcB and a Target form with one Lookup and one Dynamic field, jQuery ajax and DOM state read from the open builder):
- Lookup: source form SrcA to SrcB replaced Order by with Beta one / Beta two / Beta three and reset it to "Option label". Source set to blank cleared it down to "Option label".
- Dynamic: source form SrcA to SrcB replaced Order by with the SrcB fields.
- Fix 1 (null container): I changed the source form and removed
#frm_show_selected_fields_12before the response landed. No error was thrown (noerrororunhandledrejectionevents), and Order by reset to "Option label". - Fix 2 (
toggleFormTaxform branch): I added a fake stale option to Order by, then switched the Dynamic source type to Form Entries. The stale option was removed. - The committed
js/formidable_builder.jsbundle containsupdateOrderFieldSelectionand thefrm_order_field_lookup. A fresh webpack build here gives different module ids in every bundle, so I could not byte-compare it and compared the content instead. - Diff re-read in full (3 files,
conditionalLogic.js,fieldPreview.js, the bundle):updateOrderFieldSelectionreturns early when thefrm_order_field_<id>element is missing, so Lite alone is still safe.
Not an issue for this PR: truncated Order by labels after a form change come from Pro's show_options_for_get_values_field() (30 characters) versus the untruncated order.php. Agreed that the fix belongs in formidable-pro#6885.
Not exercised: the front-end sort order itself (the Pro half). The PR adds no JS unit tests, and CI skipped the JS unit tests job, so nothing automated covers updateOrderFieldSelection. I did not run node --test for it because no test targets it. Skills not run (manual read of the diff). Psalm and PHPUnit are green and this diff has no PHP.
Refresh the Order by field dropdown when a Lookup or Dynamic field changes its source form. Keep the available source fields in sync with the selected form.
Companion PR: https://github.com/Strategy11/formidable-pro/pull/6885
Testing
Verified with companion Pro source ordering suite: 5 tests, 12 assertions passed. Rebuilt the production admin JavaScript bundle.
ESLint, Oxlint, spelling, and production bundle build passed.
Browser verification has not been repeated for this split. Manual review: Set a Lookup or Dynamic field to order by another source field. Check ascending and descending ordering, blank sort values, and changing the source form.