Skip to content

Preserve the saved font on standalone submit buttons - #3792

Open
Crabcyborg wants to merge 3 commits into
masterfrom
fix/scoped-submit-font
Open

Crabcyborg wants to merge 3 commits into
masterfrom
fix/scoped-submit-font

Conversation

@Crabcyborg

@Crabcyborg Crabcyborg commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #3782.

A theme that sets a global --font can override the saved font on a standalone .frm_form_submit_style button. The shared submit rule now reads a Formidable-specific variable defined on the style wrapper. Buttons within the wrapper follow live font changes. Standalone buttons use the saved font stack.

Verified the cascade in an isolated Chrome fixture with a conflicting root font. Both buttons initially used Georgia. Updating the wrapper font to monospace changed only the wrapped button. The WordPress Styler UI was not exercised.

Scoped Psalm reported 18 errors on both the base and the changed template.

Summary by CodeRabbit

  • Bug Fixes
    • Submit controls now use the form’s font when no custom submit style is active, keeping their typography consistent with the rest of the form. When a custom submit style is active, its font settings continue to apply.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The stylesheet now defines a submit font-family variable when no custom submit style is active and a form font is set. Submit controls use this variable, with the configured form font as a fallback.

Changes: Submit button font family

Layer / File(s) Summary
Define and apply submit font
css/_single_theme.css.php
When no custom submit style is active and a form font is set, the template defines --frm-submit-font-family from --font. Submit controls use this variable, with the configured form font as a fallback.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: stephywells, franky-the-going-merry

Merge Risk: Minimal · up to fa6c9

Standalone submit buttons keep the saved font even when a theme defines a global font variable, and buttons inside the style wrapper follow wrapper font changes. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Preserve the saved font on standalone submit buttons" matches the stated objective of the PR. The change emits a submit-font-family variable from the form font when no custom submit style i…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Preserve the saved font on standalone submit buttons" matches the stated objective of the PR. The change emits a submit-font-family variable from the form font when no custom submit style is active, so submit controls use it, and standalone buttons keep the saved font instead of the theme's global --font. The title is specific and concise. The raw summary describes only one file (css/_single_theme.css.php), which fits a focused change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 54868ae and fa6c917.

Files selected for processing: 1

  • css/_single_theme.css.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@deepsource-io

deepsource-io Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 54868ae...fa6c917 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP Dec 1, 2026 7:49p.m. Review ↗
JavaScript Dec 1, 2026 7:49p.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.

@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Dec 1, 2026

@franky-the-going-merry franky-the-going-merry Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approve. The fix works and nothing blocks. One non-blocking note: no test covers the new variable.

Reproduced before and after in the preview env (Lite at fa6c917e1 vs. the same checkout with master's css/_single_theme.css.php). The style has font "Georgia", serif, no custom submit style, and the page sets :root{--font:"Courier New",monospace} like a theme would. One styled form plus a standalone <button class="frm_form_submit_style">:

in-form Submit standalone button
master template Georgia, serif "Courier New", monospace (the bug)
this PR Georgia, serif Georgia, serif

Before (the Standalone button is monospace, the in-form Submit is Georgia):
before

After (both Georgia):
after

Also checked:

  • Live font change in the styler: .frm_style_x.with_frm_style{--font:monospace} (the selector renderLiveVars writes) moves the in-form button to monospace, and the standalone button stays Georgia. This matches the PR description. I injected the rule by hand, so the styler UI itself was not driven.
  • --frm-submit-font-family is declared on the same element that receives the live --font, so it recomputes with it.
  • A custom submit style (submit_style=1) skips the whole submit block, so the variable is not declared. This is the same as master, not a regression.
  • Empty font (the default) skips both the declaration and the font-family line, as before.
  • Searched the repo for other font-family:var(--font, fallbacks on a button rule: none. The other var(--font) uses are unscoped inputs and labels inside the wrapper, which is correct.

Non-blocking: add a regression test. The fix has no test, and test_submit_button_rule_uses_css_vars in tests/phpunit/styles/test_FrmStylesHelper.php already covers the sibling properties of this rule. I ran this one in the harness: it passes on this branch (test_FrmStylesHelper 14 tests / 241 assertions OK) and fails against master's template.

	public function test_submit_font_uses_scoped_var() {
		$frm_style    = new FrmStyle();
		$post_content = $frm_style->get_defaults();

		$post_content['font']         = 'Georgia, serif';
		$post_content['submit_style'] = 0;

		$_POST = array(
			'action'            => 'frm_change_styling',
			'style_name'        => 'frm_style_test',
			'frm_style_setting' => array( 'post_content' => $post_content ),
		);

		$style    = '';
		$defaults = array();
		ob_start();
		include FrmAppHelper::plugin_path() . '/css/_single_theme.css.php';
		$css = ob_get_clean();

		$this->assertSame( 1, preg_match( '/\.frm_form_submit_style\s*\{([^}]*)\}/', $css, $matches ) );
		$rule = preg_replace( '/\s+/', '', $matches[1] );
		$this->assertStringContainsString( 'font-family:var(--frm-submit-font-family,Georgia,serif)', $rule );
		$this->assertStringContainsString( '--frm-submit-font-family:var(--font);', preg_replace( '/\s+/', '', $css ) );
	}

Not covered: the styler UI itself, and any theme besides the injected :root variable. CI's PHPUnit job was skipped on this PR, so the harness run above is the only PHPUnit result for it.

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant