Repository navigation
Preview most style setting changes instantly in the styler - #3782
Conversation
Output field description, check box label, label width, font, border, text and submit size settings as CSS variables in the single style template, so the styler preview can update them with JavaScript instead of requesting new CSS. Add the label color, font size and other settings Pro used directly when Pro is not active, or when Pro has the filter to remove them. Keep settings that switch a template branch, like an empty value or auto, and the values the field shape overrides on the server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 31 minutes. View limit details
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:02p.m. | Review ↗ | |
| JavaScript | Dec 1, 2026 7:02p.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.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3782 +/- ##
============================================
+ Coverage 48.77% 48.86% +0.09%
- Complexity 14330 14342 +12
============================================
Files 239 239
Lines 48151 48211 +60
============================================
+ Hits 23484 23558 +74
+ Misses 24667 24653 -14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Request Changes: the repo's existing styler JS test fails on this head, and CI skipped the job that would show it. The new live-preview behaviour itself checks out in a browser.
Blocking
tests/js/style-live-preview.test.mjs(CI job "JS unit tests / Run node --test" was skipped): 14/14 pass onmaster'sstyle.js, 5/14 pass at3a7a867(9 fail).canUpdateLivenow readspreviousValues[key], and the tests call it with two arguments (TypeError: Cannot read properties of undefined (reading 'title_color')). TheupdatePreviewtests fail for the same reason, plusgetCssVarNamesis no longer defined in theirrunInNewContextglobals. See the inline comment for the fix.- The PR description says the JS rules have no unit test because the runner cannot import them. That file already does exactly this (it loads
canUpdateLiveetc. out ofinitEditPage()with@babel/core). The new rules (switchesTemplateBranch,usesFieldShapeValue,getCssVarNames, the empty-to-or-from check) have no coverage. Add tests there as part of the fix.
Verified
node --test tests/js/style-live-preview.test.mjsat3a7a867: 5 pass, 9 fail (above). Tests run in the PHP harness (php@8.4, phpunit 9.6):test_FrmStylesHelper14/314 OK; other styles tests OK excepttest_FrmStylesController::test_front_head, a harness WP-core stylesheet path notice unrelated to this diff. The new list assertions fail whenFrmStylesHelper.phpis swapped back to master.- Live, preview env at
3a7a867with Prob52f678f9(Pro 7.0.1+ filter active), Styles page,jQuery.ajaxcounted for requests. Nofrm_change_stylingrequest for: description color / font size, border color, check label color, border radius (5px), submit shadow color, field width, font (second change). Computed style followed each change: description colorrgb(255, 0, 255), input radius 5px,--auto-width50% after field width 50%. One request, as the PR says, for: font''to a value, field height, field border width, submit height/width (from empty orauto), andlabel_color(Pro's filter removes it until the companion Pro PR lands). Circle shape + border radius 12px: one request, radius stays 30px. All 25 new variables resolve at default values on the preview wrapper. - Not exercised: the companion Pro PR #7057, flatpickr glow with Pro 7.0.1 to 7.1.1, a front-end page with a saved non-default style, underline shape, Safari/Firefox without
color-mix().
Skills not run (manual read). The PHP side (list gating by has_action / filter, empty-aware templates) looks right.
| */ | ||
| function canUpdateLive( key, values ) { | ||
| if ( ! livePreview.settings.has( key ) || ! isSafeLiveValue( values[ key ] ) ) { | ||
| function canUpdateLive( key, values, previousValues ) { |
There was a problem hiding this comment.
This signature change breaks tests/js/style-live-preview.test.mjs (14/14 on master, 5/14 here; CI skipped it). Fix in that file:
names(line 12): add'switchesTemplateBranch', 'usesFieldShapeValue', 'getCssVarNames'so the extractedcanUpdateLiveandupdatePreviewcan find them.loadDecisions(): pass a previous-values object, e.g.canUpdateLive( key, values, values )in the existing cases, and addgetCssVarNamesto theupdatePreviewglobals inloadPreview()(getCssVarNames: key => [ key ]).- Add cases for: a change from
''to a value and a value to''needs the server;field_height/submit_width/submit_heightset toauto(new or previous) needs the server;border_radiusundercircle/regular/underlineandfield_border_width/border_width_errorunderunderlineneed the server;getCssVarNames( 'field_width', { auto_width: '0' } )returns both variables and withauto_width: '1'returns one.
…eview-more-settings
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed franky's review in 767d342 (also merged master in aea7e9f):
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Approve. Both blockers from my last review are fixed at this head, and the live-preview behaviour still checks out.
Tests run: node --test tests/js/*.test.mjs at 2fa0ff6 → 133/133 pass (style-live-preview.test.mjs is back to green; it was 5/14 at 3a7a867). CI skipped the JS unit tests job, so this was a local run.
Verified
- Blocker 1 (existing test failing): fixed.
canUpdateLivecalls passpreviousValues, andgetCssVarNamesis in the stubbed globals. - Blocker 2 (new rules had no coverage): fixed. I removed each new rule from
style.jsin turn and re-ran the file: dropping the empty-to/from check fails 3 tests, droppingswitchesTemplateBranchfails 1, droppingusesFieldShapeValuefails 1. The new tests catch their rules, so they are not hollow. js/admin/style.jsis unchanged since my last review apart from the master merge, so the rules I read then still stand.- Preview env at
2fa0ff6(Styles page,jQuery.ajaxcounted forfrm_change_styling): description color and border color changed with 0 requests, and the preview wrapper's--description-color/ input border colour followed (#ff00ff,rgb(0, 255, 0)).field_heighttoautosent 1 request, andautoback to40pxsent 1 (change fromauto). Basefont_sizesent 1, as expected since the server scales font sizes from it.
Not exercised: the companion Pro PR #7057 (it still has my open change request on the Pro-derived toggle_font_size / date_head_color variables), a front-end page with a saved non-default style, underline shape, Safari/Firefox without color-mix(). Skills not run (manual read of the diff).
Stacked on #3780. Merge that one first, then retarget this PR to
master.Companion Pro PR: https://github.com/Strategy11/formidable-pro/pull/7057
In the Visual Styler, changing a label color (and most other settings) still sent a
frm_change_stylingrequest and waited for new CSS. The live preview only sets CSS variables for settings onFrmStylesHelper::get_live_preview_settings(), and many settings were left off because a CSS template printed the raw value instead of avar(). This PR moves those templates to CSS variables and adds the settings to the list, so about 30 more settings update instantly.Changes
css/_single_theme.css.phpoutputs these as CSS variables: field description font size, color, weight, style, align and margin, check box and radio label color, weight and font size, label width, font, border color, text color, and submit width, height, border width and shadow color. Rules that the template skips for an empty value keep their! empty()check.rgba()line and adds acolor-mix( in srgb, var(--border-color-active) 60%, transparent )line after it, so browsers withoutcolor-mix()keep the old glow.get_live_preview_settings()adds the settings above. Settings that Pro templates use directly are added in two groups:frm_style_live_preview_settingsfilter (7.0.1 and later), which removes the ones that Pro version still uses directly. Pro before 7.0.1 gets none of them.js/admin/style.jsstill requests new CSS when:auto, which switches a template branch;FrmStylesHelper::css_var_prepare_value.--auto-widthwhen automatic drop-down width is off, matchingget_settings_for_output.Settings that still need the server: direction, submit margin and background image, collapse icon position, the field shape itself, check box and radio layout, and progress bar colors (Pro adjusts their brightness in PHP).
With Pro 7.0.1 to 7.1.1, the flatpickr date field focus glow does not update live, because those Pro versions print it directly. The companion Pro PR fixes that.
Testing
frm_change_stylingrequest is sent.Verified in a headless browser on a dev site with Pro active, with these results and a clean debug log. PHPUnit for the style tests passes (24 tests). The new list assertions fail without the PHP change. phpcs, php-cs-fixer, rector, mago, phpstan and oxlint pass on the changed files. ESLint reports one existing
prefer-destructuringwarning on an unchanged line.tests/js/style-live-preview.test.mjscovers the JS rules: a change to or from an empty value,autofield height and submit width/height, the field shape overrides for corner radius and border widths, and the extra--auto-widthvariable for field width. Each new test fails when its rule is removed fromstyle.js.node --test tests/js/*.test.mjspasses (119 tests).🤖 Generated with Claude Code