Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions classes/views/styles/_buttons.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Font Color', 'formidable' ); ?

<div class="frm5 frm_form_field">
<label
for="frm_submit_font_size-value"
data-slider-label-for="frm_submit_font_size-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['submit_font_size'] ) ? 'for="frm_submit_font_size-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

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.

Non-blocking, repo-wide pattern (all 21 new sites in this diff, not just this one): the decision to print for="..." is duplicated per-site as a PHP conditional keyed off is_value_measured(), when slider-component.js's initListeners() already resolves valueInput.disabled for every slider at page load via the same underlying is_measured_unit() logic (slider.php:132's disabled() call). A single JS init-time pass — find the label via the existing [data-slider-label-for="..."] marker and call updateLabelFocusTarget(valueInput, !valueInput.disabled) once per slider — would let every template (this PR's 21 sites plus any future single-value slider) keep a plain static for and never need this conditional at all, closing off the exact bug class #3454/#3449/this PR keep re-fixing one site at a time. Worth a fast follow-up rather than blocking this PR, since the current approach is correct, just more maintenance surface than it needs to be.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, worth doing. Filed as #3476 (bundled with your other note below, since doing this first would make that one unnecessary).

class="frm-style-item-heading"><?php esc_html_e( 'Font Size', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand Down Expand Up @@ -147,7 +148,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Border Color', 'formidable' );

<div class="frm5 frm_form_field">
<label
for="frm_submit_border_width-value"
data-slider-label-for="frm_submit_border_width-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['submit_border_width'] ) ? 'for="frm_submit_border_width-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Border Width', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand Down Expand Up @@ -183,7 +185,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Shadow', 'formidable' ); ?></l

<div class="frm5 frm_form_field">
<label
for="frm_submit_border_radius-value"
data-slider-label-for="frm_submit_border_radius-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['submit_border_radius'] ) ? 'for="frm_submit_border_radius-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Corner Radius', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand Down
3 changes: 2 additions & 1 deletion classes/views/styles/_check-box-radio-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Color', 'formidable' ); ?></la

<div class="frm5 frm_form_field">
<label
for="frm_check_font_size-value"
data-slider-label-for="frm_check_font_size-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['check_font_size'] ) ? 'for="frm_check_font_size-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Font Size', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand Down
6 changes: 4 additions & 2 deletions classes/views/styles/_field-colors.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Border', 'formidable' ); ?></l

<div class="frm5 frm_form_field">
<label
for="frm_field_border_width-value"
data-slider-label-for="frm_field_border_width-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['field_border_width'] ) ? 'for="frm_field_border_width-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Border Width', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand Down Expand Up @@ -309,7 +310,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Border', 'formidable' ); ?></l

<div class="frm5 frm_form_field">
<label
for="frm_border_width_error-value"
data-slider-label-for="frm_border_width_error-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['border_width_error'] ) ? 'for="frm_border_width_error-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Border Width', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand Down
3 changes: 2 additions & 1 deletion classes/views/styles/_field-description.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Color', 'formidable' ); ?></la

<div class="frm5 frm_form_field">
<label
for="frm_description_font_size-value"
data-slider-label-for="frm_description_font_size-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['description_font_size'] ) ? 'for="frm_description_font_size-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Font Size', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand Down
6 changes: 4 additions & 2 deletions classes/views/styles/_field-labels.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Color', 'formidable' ); ?></la

<div class="frm5 frm_form_field">
<label
for="frm_font_size-value"
data-slider-label-for="frm_font_size-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['font_size'] ) ? 'for="frm_font_size-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Font Size', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand Down Expand Up @@ -109,7 +110,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Align', 'formidable' ); ?></la

<div class="frm5 frm_form_field">
<label
for="frm_width-value"
data-slider-label-for="frm_width-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['width'] ) ? 'for="frm_width-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Width', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field frm-md-z-index">
Expand Down
12 changes: 8 additions & 4 deletions classes/views/styles/_field-sizes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
?>
<div class="frm5 frm_form_field">
<label
for="frm_field_font_size-value"
data-slider-label-for="frm_field_font_size-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['field_font_size'] ) ? 'for="frm_field_font_size-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Font Size', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand Down Expand Up @@ -41,7 +42,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Weight', 'formidable' ); ?></l

<div class="frm5 frm_form_field">
<label
for="frm_field_height-value"
data-slider-label-for="frm_field_height-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['field_height'] ) ? 'for="frm_field_height-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Height', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand All @@ -58,7 +60,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Height', 'formidable' ); ?></l
</div>
<div class="frm5 frm_form_field">
<label
for="frm_field_width-value"
data-slider-label-for="frm_field_width-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['field_width'] ) ? 'for="frm_field_width-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Width', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand Down Expand Up @@ -111,7 +114,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Margin', 'formidable' ); ?></l
</div>
<div class="frm5 frm_form_field">
<label
for="frm_border_radius-value"
data-slider-label-for="frm_border_radius-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['border_radius'] ) ? 'for="frm_border_radius-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Corner Radius', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand Down
3 changes: 2 additions & 1 deletion classes/views/styles/_form-description.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

<div class="frm5 frm_form_field">
<label
for="frm_form_desc_size-value"
data-slider-label-for="frm_form_desc_size-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['form_desc_size'] ) ? 'for="frm_form_desc_size-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Font Size', 'formidable' ); ?>
</label>
</div>
Expand Down
6 changes: 4 additions & 2 deletions classes/views/styles/_form-messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Font Color', 'formidable' ); ?

<div class="frm5 frm_form_field">
<label
for="frm_success_font_size-value"
data-slider-label-for="frm_success_font_size-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['success_font_size'] ) ? 'for="frm_success_font_size-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Font Size', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand Down Expand Up @@ -149,7 +150,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Font Color', 'formidable' ); ?

<div class="frm5 frm_form_field">
<label
for="frm_error_font_size-value"
data-slider-label-for="frm_error_font_size-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['error_font_size'] ) ? 'for="frm_error_font_size-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Font Size', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand Down
3 changes: 2 additions & 1 deletion classes/views/styles/_form-title.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Color', 'formidable' ); ?></la

<div class="frm5 frm_form_field">
<label
for="frm_title_size-value"
data-slider-label-for="frm_title_size-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['title_size'] ) ? 'for="frm_title_size-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Font Size', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand Down
6 changes: 4 additions & 2 deletions classes/views/styles/_general.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Border Color', 'formidable' );

<div class="frm5 frm_form_field">
<label
for="frm_fieldset-value"
data-slider-label-for="frm_fieldset-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['fieldset'] ) ? 'for="frm_fieldset-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Border Width', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand Down Expand Up @@ -102,7 +103,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Padding', 'formidable' ); ?></

<div class="frm5 frm_form_field">
<label
for="frm_form_width-value"
data-slider-label-for="frm_form_width-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['form_width'] ) ? 'for="frm_form_width-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Form Width', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand Down
6 changes: 4 additions & 2 deletions classes/views/styles/_quick-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Input Field Padding', 'formida
<hr class="frm12"/>
<div class="frm5 frm_form_field">
<label
for="frm_base_font_size-value"
data-slider-label-for="frm_base_font_size-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['base_font_size'] ) ? 'for="frm_base_font_size-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

class="frm-style-item-heading"><?php esc_html_e( 'Base Font Size', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field">
Expand Down Expand Up @@ -207,7 +208,8 @@ class="frm-style-item-heading"><?php esc_html_e( 'Field Shape', 'formidable' );

<div class="frm5 frm_form_field frm_hidden" data-frm-element="field-shape-corner-radius">
<label
for="frm_style_qsettings_border_radius-value"
data-slider-label-for="frm_style_qsettings_border_radius-value"
<?php echo FrmSliderStyleComponent::is_value_measured( $style->post_content['border_radius'] ) ? 'for="frm_style_qsettings_border_radius-value"' : ''; ?>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Variable $style might not be defined


A variable has been used but not defined, which may result in warnings during program execution. This can also cause bugs since the intended usage scope of the variable is not known.

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.

Non-blocking: each of the 21 sites hand-types the {id}-value string twice (once in data-slider-label-for, once in the conditional for), plus a third time a few lines below in the FrmSliderStyleComponent constructor's 'id' option. A small static helper on FrmSliderStyleComponent — e.g. label_for_attrs( $id, $value ) printing both attributes from one $id — would cut the two adjacent literals in the <label> down to one, at all 21 sites. If going this route, note phpcs.xml:76's WordPress.Security.EscapeOutput.OutputNotEscaped sniff will need the helper allowlisted (or self-escaping) since it'd be echoed directly, same as FrmAppHelper::array_to_html_params() already handles elsewhere in this codebase.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Filed as #3476, bundled with your JS init-pass note above.

class="frm-style-item-heading"><?php esc_html_e( 'Corner Radius', 'formidable' ); ?></label>
</div>
<div class="frm7 frm_form_field frm_hidden frm-md-z-index" data-frm-element="field-shape-corner-radius">
Expand Down
27 changes: 27 additions & 0 deletions tests/cypress/e2e/Styles/styleLabelFocusTargets.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,33 @@ describe( 'Style builder labels focus their visible/interactive control', () =>
cy.focused().should( 'have.id', 'frm_fieldset-value' );
} );

it( 'A slider label outside Width/Height also drops its focus target once its unit is cleared to "Not set"', () => {
cy.intercept( 'POST', '**/admin-ajax.php', req => {
if ( req.body?.includes( 'action=frm_change_styling' ) ) {
req.alias = 'changeStyling';
}
} );

cy.visit( '/wp-admin/admin.php?page=formidable-styles&section=advanced-settings' );
cy.get( '#general-style' ).should( 'have.class', 'open' );

cy.log( '"Border Width" (frm_fieldset) ships with a measured default, so the label starts wired up' );
cy.get( '[data-slider-label-for="frm_fieldset-value"]' ).should( 'have.attr', 'for', 'frm_fieldset-value' );

cy.log( 'Clearing the unit to "Not set" disables the value input and drops the label\'s focus target' );
cy.get( '#frm_fieldset' ).closest( '.frm-slider-component' ).find( '.frm-slider-value select' ).select( '' );
cy.wait( '@changeStyling', { timeout: 10000 } );
cy.get( '#frm_fieldset-value' ).should( 'be.disabled' );
cy.get( '[data-slider-label-for="frm_fieldset-value"]' ).should( 'not.have.attr', 'for' );

cy.log( 'Choosing a measured unit again re-associates the label with the now-enabled input' );
cy.get( '#frm_fieldset' ).closest( '.frm-slider-component' ).find( '.frm-slider-value select' ).select( 'px' );
cy.wait( '@changeStyling', { timeout: 10000 } );
cy.get( '[data-slider-label-for="frm_fieldset-value"]' ).should( 'have.attr', 'for', 'frm_fieldset-value' );
cy.get( '[data-slider-label-for="frm_fieldset-value"]' ).click();
cy.focused().should( 'have.id', 'frm_fieldset-value' );
} );

it( 'A "Width"/"Height" label targets nothing while its unit defaults to "auto", and gets a working focus target once a measured unit is chosen', () => {
cy.intercept( 'POST', '**/admin-ajax.php', req => {
if ( req.body?.includes( 'action=frm_change_styling' ) ) {
Expand Down
Loading