Skip to content

Remove focus-background rule from .cmb2-wrap inputs (WP 7.0 checkbox/radio fix, #1556)#1557

Merged
jtsternberg merged 1 commit into
developfrom
copilot/fix-wp-7-checkbox-issues
May 31, 2026
Merged

Remove focus-background rule from .cmb2-wrap inputs (WP 7.0 checkbox/radio fix, #1556)#1557
jtsternberg merged 1 commit into
developfrom
copilot/fix-wp-7-checkbox-issues

Conversation

Copilot AI commented May 22, 2026

Copy link
Copy Markdown
Contributor

Fix WP 7.0 checkbox/radio focus visibility (#1556) by removing the focus-background rule

WordPress 7.0 changed checkbox/radio rendering so the checked state is the input's own background: var(--wp-admin-theme-color) fill (with a white ::before indicator on top). CMB2's .cmb2-wrap input:focus { background: #fffff8 } has equal specificity (0,2,1) and loads later, so a focused-and-checked control was painted near-white and its indicator vanished until blur — making it look like the click did nothing.

This PR removes the focus-background rule entirely, superseding the earlier :not([type=checkbox]):not([type=radio]) approach. Removal was chosen over the :not() exclusion because the exclusion raised .cmb2-wrap input:focus specificity from (0,2,1) to (0,4,1), which would break downstream overrides. Removal keeps specificity untouched.

Trade-off: text inputs/textareas lose the #fffff8 focus tint — visually negligible, and WordPress's own focus ring remains.

Regenerated all affected distributed CSS variants from source.

Copilot AI linked an issue May 22, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix checkbox visibility issue on WP 7.0 Exclude checkbox/radio inputs from CMB2 focus background styling (WP 7.0 compatibility) May 22, 2026
Copilot AI requested a review from jtsternberg May 22, 2026 00:55

@jtsternberg jtsternberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review

Context: This PR addresses the issue reported at https://wordpress.org/support/topic/weird-checkbox-behaviour-on-wp-7/ — on WP 7.0, CMB2 checkboxes appear broken because clicking them doesn't visually show as toggled. The root cause is that .cmb2-wrap input:focus { background: #fffff8; } overrides the background WP 7.0 uses to render checked-state contrast on focused checkboxes and radios.

The fix is correct and complete. The selector narrowing in _main_wrap.scss targets the root cause precisely, preserves the yellow focus background for text-like inputs, and removes it only for checkbox/radio where it conflicts with WP 7.0 rendering. All 8 compiled/minified CSS variants are consistently regenerated.

One optional scope note: The original input:focus rule also applies the yellow background to input[type=submit], input[type=button], input[type=reset], input[type=range], input[type=color], and input[type=file]. None of these have a WP 7.0 regression, so they're not blocking, but applying a yellow focus background to a submit button or color picker is arguably wrong. A follow-up to restrict the rule to only text-like input types would be reasonable — but that's out of scope for this fix and can be addressed separately.

Minor CSS note: The SCSS source uses quoted attribute values ([type="checkbox"]) while the compiled output strips the quotes ([type=checkbox]). Both are valid per spec for known HTML attributes in CSS — no action needed.

Fix is good to merge once out of draft.


Generated by Claude Code

@jtsternberg jtsternberg marked this pull request as ready for review May 30, 2026 17:31
WP 7.0 renders the checkbox/radio checked state as the input's own
background fill (background: var(--wp-admin-theme-color)). CMB2's
`.cmb2-wrap input:focus { background: #fffff8 }` rule — equal specificity
(0,2,1), loaded later — painted over that fill while focused, hiding the
white checkmark/dot until blur, so a click appeared to do nothing.

Remove the focus-background rule entirely rather than excluding
checkbox/radio via :not(), which keeps `.cmb2-wrap input:focus` specificity
unchanged for downstream overrides. Text inputs/textareas lose the
near-invisible #fffff8 focus tint; WordPress core's focus ring remains.

Verified on WP 7.0 (fixed) and 6.3.1 (no regression), on both the options
page and the post-edit metabox.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jtsternberg jtsternberg force-pushed the copilot/fix-wp-7-checkbox-issues branch from fef51d7 to 9e7093d Compare May 31, 2026 00:55
@jtsternberg jtsternberg changed the title Exclude checkbox/radio inputs from CMB2 focus background styling (WP 7.0 compatibility) Remove focus-background rule from .cmb2-wrap inputs (WP 7.0 checkbox/radio fix, #1556) May 31, 2026
@jtsternberg

Copy link
Copy Markdown
Member

QA'd locally against WP 7.0 and WP 6.3.1, on both the options page and the post-edit (block-editor) metabox:

WP Before After (this PR)
7.0 focused+checked checkbox/radio render empty (bug) themed checked fill preserved ✓
6.3.1 correct no regression ✓ (text-input tint removed, intended)

Verified via CSSOM (no .cmb2-wrap …:focus background rule remains) and computed styles, not just screenshots.

@jtsternberg jtsternberg merged commit 0344858 into develop May 31, 2026
18 checks passed
@jtsternberg jtsternberg deleted the copilot/fix-wp-7-checkbox-issues branch May 31, 2026 01:02
jtsternberg added a commit that referenced this pull request May 31, 2026
Orphaned by #1556 (the .cmb2-wrap input/textarea :focus background rule
that referenced it was removed in PR #1557). No compiled CSS change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WP 7.0 Checkbox issues

2 participants