Skip to content

add "for" accessibility to style editor elements, add form descriptio… #2011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 22, 2024

Conversation

Liviu-p
Copy link
Contributor

@Liviu-p Liviu-p commented Sep 30, 2024

…n font size option, add extra check for base font size in order to avoid undefined when used as non-numeric

Fixes https://github.com/Strategy11/formidable-pro/issues/5382
Also fixes https://github.com/Strategy11/formidable-pro/issues/5391

Related Pro PR https://github.com/Strategy11/formidable-pro/pull/5400

This update adds missing for attributes to labels so clicking a label will focus the input (in the new visual styler editor).
While also adding the missing font size setting for form descriptions as well.

…n font size option, add extra check for base font size in order to avoid undefined when used as non-numeric
Copy link
Contributor

coderabbitai bot commented Sep 30, 2024

Walkthrough

The changes involve modifications to various PHP files related to form styling and accessibility improvements. Key updates include adding for attributes to <label> elements to enhance accessibility by linking them to their corresponding input fields. Additionally, the get_base_font_size_scale method in the FrmStylesHelper class has been updated to prevent division by zero by ensuring that the font size value is numeric and not zero. A new component for font size configuration has also been introduced.

Changes

File Path Change Summary
classes/helpers/FrmStylesHelper.php Modified get_base_font_size_scale method to add a condition ensuring $value is not zero, preventing division by zero.
classes/views/styles/_buttons.php Updated <label> elements to include for attributes linking them to corresponding input fields, enhancing accessibility.
classes/views/styles/_check-box-radio-fields.php Added for attributes to <label> elements for checkboxes and radio buttons, improving accessibility.
classes/views/styles/_field-colors.php Updated <label> elements to include for attributes for various color settings, enhancing accessibility.
classes/views/styles/_field-description.php Added for attributes to labels for styling options, standardizing IDs for input elements to improve semantic structure.
classes/views/styles/_field-labels.php Added for attributes to several <label> elements, linking them to their corresponding input fields.
classes/views/styles/_field-sizes.php Updated <label> elements to include for attributes for various form fields, enhancing accessibility.
classes/views/styles/_form-description.php Introduced a new section for configuring font size with a FrmSliderStyleComponent, including a label for font size input.
classes/views/styles/_form-messages.php Added for attributes to <label> elements for message styling options, improving accessibility.
classes/views/styles/_form-title.php Updated labels for "Color," "Font Size," and "Margin" to include for attributes, linking them to respective input elements.
classes/views/styles/_general.php Added for attributes to various <label> elements, linking them to input fields, and updated instantiations of components to include id parameters.
classes/views/styles/_quick-settings.php Updated <label> elements to include for attributes and modified IDs for color and margin/padding settings to follow a consistent naming convention.

Possibly related PRs

Suggested reviewers

  • shervElmi
  • Liviu-p

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b40b76d and b6e0e62.

📒 Files selected for processing (2)
  • classes/helpers/FrmStylesHelper.php (1 hunks)
  • classes/views/styles/_quick-settings.php (10 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • classes/helpers/FrmStylesHelper.php
  • classes/views/styles/_quick-settings.php

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (9)
classes/views/styles/_form-title.php (1)

42-46: LGTM: Accessibility improvement for Margin label with a suggestion

The addition of the for="frm_title_margins" attribute to the label element is a positive change. It correctly associates the label with its corresponding input (slider component), enhancing accessibility for users relying on assistive technologies.

However, given that the margin input consists of two independent fields (top and bottom), consider the following suggestion:

To further improve accessibility, you might want to add separate labels for the top and bottom margin inputs. This would allow screen readers to distinguish between the two inputs more clearly. Here's a potential implementation:

 <div class="frm5 frm_form_field">
 	<label 
 		for="frm_title_margins"
 		class="frm-style-item-heading"><?php esc_html_e( 'Margin', 'formidable' ); ?></label>
 </div>
 <div class="frm7 frm_form_field">
 	<?php
 	new FrmSliderStyleComponent(
 		null,
 		$style->post_content['title_margin_top'],
 		array(
 			'id'                 => 'frm_title_margins',
 			'type'               => 'vertical-margin',
 			'max_value'          => 100,
 			'independent_fields' => array(
 				array(
 					'name'  => $frm_style->get_field_name( 'title_margin_top' ),
 					'value' => $style->post_content['title_margin_top'],
 					'id'    => 'frm_title_margin_top',
 					'type'  => 'top',
+					'label' => '<span class="frm_screen_reader_text">' . esc_html__( 'Top Margin', 'formidable' ) . '</span>',
 				),
 				array(
 					'name'  => $frm_style->get_field_name( 'title_margin_bottom' ),
 					'value' => $style->post_content['title_margin_bottom'],
 					'id'    => 'frm_title_margin_bottom',
 					'type'  => 'bottom',
+					'label' => '<span class="frm_screen_reader_text">' . esc_html__( 'Bottom Margin', 'formidable' ) . '</span>',
 				),
 			),
 		)
 	);
 	?>
 </div>

This change adds visually hidden labels for screen readers, providing more context for each margin input while maintaining the current visual design.

classes/views/styles/_form-description.php (1)

7-24: LGTM! Consider adding a unit to the label for consistency.

The new font size configuration section is well-structured and consistent with other sections. The use of FrmSliderStyleComponent and the inclusion of the for attribute in the label improve functionality and accessibility.

For consistency with other size-related labels in the form (if any), consider adding the unit (e.g., "px" or "em") to the label:

-		class="frm-style-item-heading"><?php esc_html_e( 'Font Size', 'formidable' ); ?>
+		class="frm-style-item-heading"><?php esc_html_e( 'Font Size (px)', 'formidable' ); ?>

This change would provide users with immediate clarity about the unit of measurement being used.

classes/views/styles/_check-box-radio-fields.php (2)

61-63: Great accessibility enhancement, with a minor suggestion.

The addition of the for="frm_check_align" attribute to the label element is an excellent improvement for accessibility. This change ensures that the label is correctly associated with its corresponding dropdown input, enhancing the form's usability for users of assistive technologies.

However, the label text "Check Box" might be slightly confusing as it refers to the alignment of checkboxes, not a single checkbox.

Consider changing the label text to "Checkbox Alignment" or "Checkbox Layout" for better clarity:

-		class="frm-style-item-heading"><?php esc_html_e( 'Check Box', 'formidable' ); ?></label>
+		class="frm-style-item-heading"><?php esc_html_e( 'Checkbox Alignment', 'formidable' ); ?></label>

82-84: Excellent accessibility improvement, with a minor suggestion.

The addition of the for="frm_radio_align" attribute to the label element is a great enhancement for accessibility. This change ensures that the label is properly associated with its corresponding dropdown input, improving the form's usability for users of assistive technologies.

However, similar to the previous suggestion, the label text "Radio" might be slightly confusing as it refers to the alignment of radio buttons, not a single radio button.

Consider changing the label text to "Radio Button Alignment" or "Radio Button Layout" for better clarity and consistency with the previous suggestion:

-		class="frm-style-item-heading"><?php esc_html_e( 'Radio', 'formidable' ); ?></label>
+		class="frm-style-item-heading"><?php esc_html_e( 'Radio Button Alignment', 'formidable' ); ?></label>
classes/views/styles/_field-description.php (1)

Mismatch Found in Multiple Sections

The verification script identified mismatches between for attributes in labels and their corresponding id attributes in the following sections:

  1. Color
    • for: frm_description_color
    • id: (incorrectly matched)
  2. Margin
    • for: frm_description_margin
    • id: (incorrectly matched)
  3. Style
    • for: frm_description_style
    • id: (incorrectly matched)
  4. Weight
    • for: frm_description_weight
    • id: (incorrectly matched)

Action Required:

  • Ensure that each label's for attribute exactly matches the id of its corresponding form control in all four sections listed above.

Once these mismatches are corrected, the accessibility improvements will be fully realized across all form styling controls.

🔗 Analysis chain

Line range hint 1-118: Summary of accessibility improvements and remaining issue

Overall, the changes in this file significantly improve accessibility by adding for attributes to label elements and ensuring they match the id attributes of their corresponding form controls. This aligns well with the PR objectives of enhancing accessibility features.

However, there is one issue that needs to be addressed:

  1. In the Font Size section (lines 25-27), the for attribute of the label and the id of the slider component are mismatched. This should be corrected to ensure proper accessibility for the Font Size control.

Once this issue is resolved, the accessibility improvements in this file will be complete and consistent across all form styling controls.

To ensure all for attributes match their corresponding id attributes, you can run the following script:

This script will help identify any remaining mismatches between for and id attributes in the file.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all 'for' attributes match their corresponding 'id' attributes

# Test: Check for mismatches between 'for' and 'id' attributes
rg --type php -e 'for="([^"]+)"' -e 'id="([^"]+)"' classes/views/styles/_field-description.php | \
awk -F'"' '{print $2}' | sort | uniq -c | awk '$1 == 1 {print "Mismatch found for: " $2}'

Length of output: 358

classes/views/styles/_field-labels.php (1)

57-59: LGTM with a suggestion: Improved accessibility for the Weight label

The addition of the for attribute to the label element enhances accessibility by associating it with the corresponding input field (id="frm_required_weight"). This change improves the user experience for those using assistive technologies.

However, there's a minor inconsistency between the label text "Weight" and the input ID "frm_required_weight". Consider clarifying whether this is for general weight or specifically for required fields.

Consider updating either the label text or the input ID for consistency:

  1. If it's for required fields: Change the label to "Required Weight"
  2. If it's for general weight: Change the input ID to "frm_weight"
classes/helpers/FrmStylesHelper.php (3)

Line range hint 4-4: Consider addressing TODO comments.

There are TODO comments in the file, such as the one on line 4. These indicate incomplete features or documentation. It's good practice to address these comments to ensure all features are fully implemented and documented.

Would you like me to create a GitHub issue to track the completion of these TODO items?


Line range hint 1068-1072: Remove deprecated methods in future versions.

The maybe_include_font_icon_css method is marked as deprecated. Consider removing this method in future versions to keep the codebase clean and prevent usage of outdated functionality.

In the next major version update, remove this deprecated method and update any remaining calls to it throughout the codebase.


Line range hint 1-1072: Consider refactoring for better separation of concerns.

The FrmStylesHelper class has a large number of responsibilities, including color manipulation, CSS generation, and various utility functions. This might violate the Single Responsibility Principle.

Consider refactoring this class into smaller, more focused classes. For example:

  • ColorManipulator for color-related functions
  • CSSGenerator for CSS and variable generation
  • FontSizeCalculator for font size related calculations

This would improve maintainability and make the code easier to test and extend in the future.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 015fc68 and c1919d3.

📒 Files selected for processing (12)
  • classes/helpers/FrmStylesHelper.php (1 hunks)
  • classes/views/styles/_buttons.php (18 hunks)
  • classes/views/styles/_check-box-radio-fields.php (5 hunks)
  • classes/views/styles/_field-colors.php (16 hunks)
  • classes/views/styles/_field-description.php (5 hunks)
  • classes/views/styles/_field-labels.php (8 hunks)
  • classes/views/styles/_field-sizes.php (7 hunks)
  • classes/views/styles/_form-description.php (1 hunks)
  • classes/views/styles/_form-messages.php (8 hunks)
  • classes/views/styles/_form-title.php (3 hunks)
  • classes/views/styles/_general.php (8 hunks)
  • classes/views/styles/_quick-settings.php (10 hunks)
🔇 Additional comments (80)
classes/views/styles/_form-title.php (3)

6-10: LGTM: Accessibility improvement for Color label

The addition of the for="frm_fieldset_color" attribute to the label element is a positive change. It correctly associates the label with its corresponding input (color picker), enhancing accessibility for users relying on assistive technologies.


24-28: LGTM: Accessibility improvement for Font Size label

The addition of the for="frm_title_size" attribute to the label element is a positive change. It correctly associates the label with its corresponding input (slider component), enhancing accessibility for users relying on assistive technologies.


Line range hint 1-73: Overall assessment: Accessibility improvements successfully implemented

The changes made to this file consistently improve accessibility by adding for attributes to all label elements, correctly associating them with their corresponding inputs. These modifications align well with the PR objectives of enhancing accessibility for the style editor elements.

The code structure remains clean and consistent throughout the file. No additional issues or necessary improvements were identified beyond the suggestion for the margin inputs.

classes/views/styles/_check-box-radio-fields.php (4)

7-9: Excellent accessibility improvement!

The addition of the for="frm_check_label_color" attribute to the label element is a great enhancement for accessibility. This change ensures that the label is properly associated with its corresponding input field, making it easier for users of assistive technologies to interact with the form.


25-27: Great accessibility enhancement!

Adding the for="frm_check_font_size" attribute to the label element is an excellent improvement for accessibility. This change ensures that the label is correctly associated with its corresponding input field, enhancing the user experience for those using assistive technologies.


43-45: Excellent accessibility improvement!

The addition of the for="frm_check_weight" attribute to the label element is a valuable enhancement for accessibility. This change ensures that the label is properly associated with its corresponding dropdown input, improving the form's usability for users of assistive technologies.


Line range hint 1-101: Overall excellent accessibility improvements!

The changes made in this file consistently enhance the accessibility of the form by adding for attributes to all label elements. This improvement ensures that each label is properly associated with its corresponding input field, significantly benefiting users of assistive technologies.

The implementation is consistent across all modified segments, demonstrating a thorough approach to improving the form's accessibility. These changes align perfectly with the PR objectives and contribute to a more inclusive user experience.

Great job on these accessibility enhancements!

classes/views/styles/_field-description.php (5)

7-9: LGTM: Accessibility improvement for Color field

The addition of the for attribute to the label element, matching the id of the color picker component, enhances accessibility. This change correctly associates the label with its form control, following best practices for web accessibility.


43-45: LGTM: Accessibility improvement for Weight field

The addition of the for attribute to the label element, matching the id of the dropdown component, enhances accessibility. This change correctly associates the label with its form control, following best practices for web accessibility.


61-63: LGTM: Accessibility improvement for Style field

The changes in this section enhance accessibility:

  1. Addition of the for attribute to the label element.
  2. Updating the id of the dropdown component to "frm_description_style".
  3. Ensuring the for attribute matches the updated id.

These modifications correctly associate the label with its form control, following best practices for web accessibility.

Also applies to: 71-71


82-84: LGTM: Accessibility improvement for Align field

The changes in this section enhance accessibility:

  1. Addition of the for attribute to the label element.
  2. Explicit setting of the id for the alignment component to "frm_description_align".
  3. Ensuring the for attribute matches the id of the component.

These modifications correctly associate the label with its form control, following best practices for web accessibility.

Also applies to: 92-92


100-102: LGTM: Accessibility improvement for Margin field

The addition of the for attribute to the label element, matching the id of the slider component, enhances accessibility. This change correctly associates the label with its form control, following best practices for web accessibility.

classes/views/styles/_field-sizes.php (7)

7-9: LGTM: Accessibility improvement for Font Size field

The addition of the for attribute to the label, matching the id of the corresponding input component, enhances accessibility. This change follows best practices for form accessibility.


25-27: LGTM: Accessibility improvement for Weight field

The addition of the for attribute to the label, matching the id of the corresponding input component, enhances accessibility. This change follows best practices for form accessibility.


43-45: LGTM: Accessibility improvement for Height field

The addition of the for attribute to the label, matching the id of the corresponding input component, enhances accessibility. This change follows best practices for form accessibility.


60-62: LGTM: Accessibility improvement for Width field

The addition of the for attribute to the label, matching the id of the corresponding input component, enhances accessibility. This change follows best practices for form accessibility.


77-79: LGTM: Accessibility improvement for Padding field

The addition of the for attribute to the label, matching the id of the corresponding input component, enhances accessibility. This change follows best practices for form accessibility.


95-97: LGTM: Accessibility improvement for Margin field

The addition of the for attribute to the label, matching the id of the corresponding input component, enhances accessibility. This change follows best practices for form accessibility.


113-115: LGTM: Accessibility improvement for Corner Radius field

The addition of the for attribute to the label, matching the id of the corresponding input component, enhances accessibility. This change follows best practices for form accessibility.

Summary of changes:
All modified segments in this file consistently add for attributes to labels, improving accessibility for the following fields:

  1. Font Size
  2. Weight
  3. Height
  4. Width
  5. Padding
  6. Margin
  7. Corner Radius

These changes align with the PR objectives of enhancing accessibility features within the style editor elements.

classes/views/styles/_form-messages.php (7)

21-23: LGTM: Improved accessibility for success background color label

The addition of the for attribute to the label element, matching the id of its corresponding input field, enhances accessibility. This change allows users of assistive technologies to better navigate and interact with the form.


39-41: LGTM: Enhanced accessibility for success border color label

The for attribute added to the label element, correctly associated with its input field's id, improves the form's accessibility. This change is consistent with best practices and helps users navigate the form more effectively.


57-59: LGTM: Accessibility improvement for success font color label

The addition of the for attribute to the label, correctly linked to its input field's id, enhances the form's accessibility. This change maintains consistency with previous improvements and adheres to accessibility best practices.


74-78: LGTM: New success font size field with proper accessibility

A new form field for success message font size has been added, complete with an accessible label using the for attribute. This addition aligns with the PR objectives and maintains consistency with the existing code structure and accessibility improvements.


97-99: LGTM: Improved accessibility for error background color label

The addition of the for attribute to the label element, correctly associated with its input field's id, enhances the accessibility of the error message section. This change maintains consistency with previous improvements and adheres to accessibility best practices.


115-117: LGTM: Comprehensive accessibility improvements for error message styling

The changes in this segment consistently improve accessibility across the error message styling options:

  1. Error border color label (lines 115-117)
  2. Error font color label (lines 133-135)
  3. New error font size field and label (lines 150-154)

All labels now include for attributes correctly associated with their corresponding input field ids. The addition of the error font size field maintains consistency with the success message section and aligns with the PR objectives.

These changes demonstrate a thorough approach to enhancing form accessibility and usability.

Also applies to: 133-135, 150-154


Line range hint 1-170: Summary: Excellent accessibility improvements and feature additions

The changes in this file demonstrate a comprehensive approach to enhancing form accessibility and user customization options:

  1. Accessibility improvements: All form labels now include for attributes correctly associated with their corresponding input fields, significantly improving the form's usability for users of assistive technologies.

  2. New font size options: Font size controls have been added for both success and error messages, allowing for greater customization of form appearance. This addition aligns well with the PR objectives.

  3. Consistency: The changes are implemented consistently across both the success and error message sections, maintaining a cohesive user experience.

These modifications collectively contribute to a more accessible, user-friendly, and customizable form styling interface. Great work on improving the overall quality of the Formidable Forms plugin!

classes/views/styles/_field-labels.php (7)

21-23: LGTM: Improved accessibility for the Color label

The addition of the for attribute to the label element enhances accessibility by correctly associating it with the corresponding input field (id="frm_label_color"). This change allows users of assistive technologies to better interact with the form.


39-41: LGTM: Improved accessibility for the Font Size label

The addition of the for attribute to the label element enhances accessibility by correctly associating it with the corresponding input field (id="frm_font_size"). This change improves the user experience for those using assistive technologies.


75-77: LGTM: Improved accessibility for the Position label

The addition of the for attribute to the label element enhances accessibility by correctly associating it with the corresponding input field (id="frm_position"). This change improves the user experience for those using assistive technologies.


93-95: LGTM: Improved accessibility and consistency for the Align label

The changes enhance accessibility and maintain consistency:

  1. The addition of the for attribute to the label element correctly associates it with the input field.
  2. The input field's id has been updated to "frm_label_align" to match the label's for attribute.

These modifications improve the user experience for those using assistive technologies and ensure proper label-input association.

Also applies to: 103-103


111-113: LGTM: Improved accessibility for the Width label

The addition of the for attribute to the label element enhances accessibility by correctly associating it with the corresponding input field (id="frm_width"). This change improves the user experience for those using assistive technologies.


129-131: LGTM: Improved accessibility for multiple labels

The addition of for attributes to the following labels enhances accessibility:

  1. Padding label (for="frm_label_padding")
  2. Color label in the Required Indicator section (for="frm_required_color")
  3. Weight label in the Required Indicator section (for="frm_required_weight")

These changes correctly associate the labels with their corresponding input fields, improving the user experience for those using assistive technologies.

Also applies to: 152-154, 170-172


Line range hint 1-189: Summary: Significant accessibility improvements across the file

The changes made to this file consistently enhance the accessibility of the form by adding for attributes to label elements and ensuring they correctly correspond to their associated input fields. These modifications align well with the PR objectives of improving accessibility features within the style editor elements.

Key improvements:

  1. All label elements now have for attributes, properly linking them to their respective input fields.
  2. The changes cover various form elements including color pickers, font size selectors, dropdowns, and sliders.
  3. The modifications improve the user experience for individuals using assistive technologies.

One minor suggestion was made regarding the consistency of the "Weight" label in the general settings section. Overall, these changes represent a significant step forward in making the form more accessible and user-friendly.

classes/views/styles/_general.php (11)

7-9: LGTM: Accessibility improvement for Font Family label

The addition of the for attribute to the label element is a positive change. It correctly associates the label with its corresponding input field (id="frm_font"), enhancing accessibility for users relying on assistive technologies.


31-35: LGTM: Accessibility improvement for Alignment label

The addition of the for attribute to the label element for Alignment is a positive change. It correctly associates the label with its corresponding input field (id="frm_form_align"), enhancing accessibility.


41-43: LGTM: Added id parameter to FrmAlignStyleComponent

The addition of the 'id' parameter to the FrmAlignStyleComponent instantiation is correct. This change ensures that the component has the proper id ("frm_form_align") to match the label's for attribute, completing the accessibility improvement for the Alignment field.


48-52: LGTM: Accessibility improvement for Border Color label

The addition of the for attribute to the label element for Border Color is a positive change. It correctly associates the label with its corresponding input field (id="frm_fieldset_color"), enhancing accessibility for users relying on assistive technologies.


66-70: LGTM: Accessibility improvement for Border Width label

The addition of the for attribute to the label element for Border Width is a positive change. It correctly associates the label with its corresponding input field (id="frm_fieldset"), enhancing accessibility for users relying on assistive technologies.


84-88: LGTM: Accessibility improvement for Padding label

The addition of the for attribute to the label element for Padding is a positive change. It correctly associates the label with its corresponding input field (id="frm_fieldset_padding"), enhancing accessibility for users relying on assistive technologies.


103-107: LGTM: Accessibility improvement for Form Width label

The addition of the for attribute to the label element for Form Width is a positive change. It correctly associates the label with its corresponding input field (id="frm_form_width"), enhancing accessibility for users relying on assistive technologies.


121-125: LGTM: Accessibility improvement for Direction label and component

The changes made to the Direction section are positive:

  1. The addition of the for attribute to the label element correctly associates it with the input field (id="frm_direction").
  2. The 'id' parameter added to the FrmDirectionStyleComponent instantiation ensures the component has the proper id to match the label's for attribute.

These changes enhance accessibility for users relying on assistive technologies.

Also applies to: 131-133


139-141: LGTM: Accessibility improvement for Override Theme label

The addition of the for attribute to the label element for Override Theme is a positive change. It correctly associates the label with its corresponding input field (id="frm_important_style"), enhancing accessibility for users relying on assistive technologies.


161-165: LGTM: Accessibility improvements for Center Form and Style Class labels

The changes made to the Center Form and Style Class sections are positive:

  1. The addition of the for attribute to the Center Form label correctly associates it with the input field (id="frm_center_form").
  2. The addition of the for attribute to the Style Class label correctly associates it with the input field (id="frm_style_class").

These changes enhance accessibility for users relying on assistive technologies.

Also applies to: 180-184


Line range hint 1-184: Summary: Excellent accessibility improvements across the file

This pull request successfully enhances the accessibility of the style editor elements in the Formidable Forms plugin. The changes include:

  1. Adding for attributes to all <label> elements, linking them to their corresponding input fields.
  2. Ensuring that all related input fields and components have matching id attributes.

These modifications significantly improve the usability of the form for users relying on assistive technologies, as they can now navigate more easily between labels and their associated input fields. The changes are consistent throughout the file and align perfectly with the PR objectives.

No issues or potential problems were identified in the implementation. Great job on improving the plugin's accessibility!

classes/views/styles/_quick-settings.php (8)

11-15: Accessibility improvement: Label association

The addition of the for attribute to the label element is a positive change. It improves accessibility by explicitly associating the label with its corresponding input field, which is crucial for users relying on assistive technologies.


41-45: Consistent accessibility improvement

The addition of the for attribute to this label element is consistent with the previous change. It maintains the improved accessibility throughout the form, ensuring that all labels are properly associated with their input fields.


66-70: Continued accessibility improvements

The addition of the for attribute to the "Field Border" label maintains the pattern of accessibility improvements. This consistent approach ensures that all form elements are properly labeled and accessible.


89-93: Comprehensive accessibility enhancements

The addition of the for attribute to the "Button Text" label completes the set of accessibility improvements for the color-related form elements. These changes collectively enhance the form's usability for all users, particularly those relying on assistive technologies.


114-118: Accessibility improvement and consistent ID naming

The addition of the for attribute to the "Vertical Spacing" label and the corresponding update to the input's ID improve accessibility. The ID naming convention (frm_field_margin) is consistent with other non-color elements, maintaining a clear and logical structure.

Also applies to: 125-125


135-139: Consistent accessibility and ID naming improvements

The changes to the "Input Field Padding" label and input maintain the pattern of accessibility improvements and consistent ID naming for non-color elements. This consistency helps maintain a clear structure and improves the overall accessibility of the form.

Also applies to: 146-146


156-160: Accessibility improvements and new hidden input

The changes to the "Base Font Size" label and input maintain the pattern of accessibility improvements and consistent ID naming.

However, I noticed a new hidden input field for "use_base_font_size" with a default value of "false". Could you please clarify the purpose of this field and how it interacts with the advanced settings?

Also applies to: 174-174


186-188: Accessibility improvements and conditional display

The changes to the "Field Shape" and "Corner Radius" labels and inputs continue the pattern of accessibility improvements and consistent ID naming. This maintains the overall enhanced accessibility of the form.

I noticed that the "Corner Radius" section is wrapped in a div with a "frm_hidden" class. This suggests that this section may be conditionally displayed, possibly based on the selected field shape. This approach allows for a dynamic and responsive user interface.

Also applies to: 203-205

classes/views/styles/_field-colors.php (13)

23-25: LGTM: Improved accessibility for background color label

The addition of the for attribute to the label element, linking it to the input with id "frm_bg_color", enhances accessibility. This change follows best practices by explicitly associating the label with its corresponding input field.


41-43: LGTM: Enhanced accessibility for field text color label

The addition of the for attribute to the label element, associating it with the input id "frm_text_color", improves accessibility. This change aligns with best practices for creating accessible web forms.


59-61: LGTM: Accessibility improvement for border color label

The for attribute has been correctly added to the label element, linking it to the input with id "frm_border_color". This change enhances the form's accessibility by ensuring proper association between the label and its corresponding input field.


77-79: LGTM: Accessibility enhancement for border width label

The addition of the for attribute to the label element, connecting it to the input with id "frm_field_border_width", improves the form's accessibility. This change ensures that screen readers can correctly associate the label with its input field.


95-97: LGTM: Improved accessibility for border style label

The for attribute has been appropriately added to the label element, linking it to the input with id "frm_field_border_style". This change enhances the form's accessibility by ensuring proper association between the label and its corresponding input field.


118-120: LGTM: Enhanced accessibility for box shadow label

The addition of the for attribute to the label element, associating it with the input id "frm_box_shadow", improves the form's accessibility. This change aligns with best practices for creating accessible web forms.


141-143: LGTM: Accessibility improvement for active state background color label

The for attribute has been correctly added to the label element, linking it to the input with id "frm_bg_color_active". This change enhances the form's accessibility by ensuring proper association between the label and its corresponding input field for the active state.


159-161: LGTM: Enhanced accessibility for active state border color label

The addition of the for attribute to the label element, connecting it to the input with id "frm_border_color_active", improves the form's accessibility. This change ensures that screen readers can correctly associate the label with its input field for the active state border color.


199-201: LGTM: Accessibility enhancement for read-only state background color label

The for attribute has been appropriately added to the label element, linking it to the input with id "frm_bg_color_disabled". This change improves the form's accessibility by ensuring proper association between the label and its corresponding input field for the read-only state background color.


217-219: LGTM: Improved accessibility for read-only state field text color label

The addition of the for attribute to the label element, associating it with the input id "frm_text_color_disabled", enhances the form's accessibility. This change follows best practices by explicitly linking the label to its corresponding input field for the read-only state field text color.


235-237: LGTM: Enhanced accessibility for read-only state border color label

The for attribute has been correctly added to the label element, linking it to the input with id "frm_border_color_disabled". This change improves the form's accessibility by ensuring proper association between the label and its corresponding input field for the read-only state border color.


257-259: LGTM: Comprehensive accessibility improvements for Error state labels

The changes in these line ranges consistently improve the accessibility of the form by adding for attributes to labels in the Error state. This includes labels for:

  • Background color (lines 257-259)
  • Field text color (lines 275-277)
  • Border color (lines 293-295)
  • Border width (lines 310-314, newly added)
  • Border style (lines 329-331)

These modifications ensure proper associations between labels and their corresponding input fields, enhancing the form's usability for users relying on assistive technologies.

Also applies to: 275-277, 293-295, 310-314, 329-331


Line range hint 1-358: Summary: Excellent accessibility improvements aligned with PR objectives

This review has examined all the changes made to the classes/views/styles/_field-colors.php file. The modifications consistently improve the form's accessibility by adding for attributes to label elements, ensuring proper associations with their corresponding input fields. These changes cover all form states (Default, Active, Read Only, and Error) and various styling aspects (background color, text color, border properties, etc.).

The implemented changes align perfectly with the PR objectives of enhancing accessibility features within the style editor elements. They contribute to a more inclusive user experience, particularly benefiting users who rely on assistive technologies.

Overall, these modifications represent a significant step forward in improving the accessibility of the Formidable Forms plugin. Great job on implementing these important accessibility enhancements!

classes/views/styles/_buttons.php (13)

37-39: LGTM: Improved accessibility for font color label

The addition of the for attribute to the label element enhances accessibility by explicitly associating it with the corresponding input field (frm_submit_text_color). This change allows assistive technologies to correctly identify the relationship between the label and the input, improving the user experience for those using screen readers or other assistive devices.


54-58: LGTM: Enhanced accessibility for font size label

The addition of the for attribute to the label element for font size improves accessibility by creating an explicit association with the corresponding input field (frm_submit_font_size). This change ensures that users of assistive technologies can easily understand and interact with the font size control.


73-75: LGTM: Improved accessibility for weight label

The addition of the for attribute to the label element for weight enhances accessibility by creating a clear association with the corresponding input field (frm_submit_weight). This change improves the usability of the form for users relying on assistive technologies.


90-94: LGTM: Enhanced accessibility for width label

The addition of the for attribute to the label element for width improves accessibility by explicitly linking it to the corresponding input field (frm_submit_width). This change ensures that users of assistive technologies can easily understand and interact with the width control.


109-113: LGTM: Improved accessibility for height label

The addition of the for attribute to the label element for height enhances accessibility by creating a clear association with the corresponding input field (frm_submit_height). This change improves the usability of the form for users relying on assistive technologies.


128-130: LGTM: Enhanced accessibility for border color label

The addition of the for attribute to the label element for border color improves accessibility by explicitly linking it to the corresponding input field (frm_submit_border_color). This change ensures that users of assistive technologies can easily understand and interact with the border color control.


145-149: LGTM: Improved accessibility for border width label

The addition of the for attribute to the label element for border width enhances accessibility by creating a clear association with the corresponding input field (frm_submit_border_width). This change improves the usability of the form for users relying on assistive technologies.


164-166: LGTM: Enhanced accessibility for shadow color label

The addition of the for attribute to the label element for shadow color improves accessibility by explicitly linking it to the corresponding input field (frm_submit_shadow_color). This change ensures that users of assistive technologies can easily understand and interact with the shadow color control.


181-185: LGTM: Improved accessibility for corner radius label

The addition of the for attribute to the label element for corner radius enhances accessibility by creating a clear association with the corresponding input field (frm_submit_border_radius). This change improves the usability of the form for users relying on assistive technologies.


Line range hint 200-227: LGTM: Enhanced accessibility for margin and padding labels

The addition of for attributes to the label elements for margin (frm_submit_margin) and padding (frm_submit_padding) improves accessibility by explicitly linking them to their corresponding input fields. These changes ensure that users of assistive technologies can easily understand and interact with the margin and padding controls.

The existing code between the changed lines, including the tooltip for the margin label, remains unaffected and continues to provide additional context for users.


243-245: LGTM: Improved accessibility for disable styling label

The addition of the for attribute to the label element for disabling submit button styling enhances accessibility by creating a clear association with the corresponding input field (frm_submit_style). This change improves the usability of the form for users relying on assistive technologies, especially for this important toggle that affects the overall button styling.


Line range hint 270-366: LGTM: Comprehensive accessibility improvements for hover and active states

The addition of for attributes to the label elements for hover and active states of the submit button (background color, font color, and border color) significantly enhances accessibility. These changes create explicit associations between labels and their corresponding input fields:

  • Hover state: frm_submit_hover_bg_color, frm_submit_hover_color, frm_submit_hover_border_color
  • Active state: frm_submit_active_bg_color, frm_submit_active_color, frm_submit_active_border_color

The consistency in applying these accessibility improvements across different button states is commendable. This approach ensures a uniform and inclusive user experience for all form interactions, benefiting users who rely on assistive technologies.


Line range hint 1-384: Overall: Excellent accessibility improvements throughout the file

The changes made in this file demonstrate a comprehensive approach to enhancing accessibility in the form styling interface. By consistently adding for attributes to label elements and ensuring they correctly match their corresponding input field IDs, the code now provides a much more accessible experience for users relying on assistive technologies.

These improvements cover various aspects of button styling, including:

  • Default state properties (font color, size, weight, dimensions, borders, shadows, etc.)
  • Hover state properties
  • Active state properties
  • Toggle for disabling button styling

The consistency in applying these changes across different form elements and button states is commendable and reflects a thorough understanding of accessibility best practices.

These enhancements will significantly improve the usability of the Formidable Forms plugin for all users, particularly those using screen readers or other assistive devices. Great job on prioritizing accessibility in this update!

classes/helpers/FrmStylesHelper.php (2)

Line range hint 1-1072: Overall assessment: Approved with suggestions for future improvements

The changes made to the get_base_font_size_scale method are beneficial and improve the code's robustness. However, there are several areas where the file could be improved:

  1. Address TODO comments to complete any unfinished features or documentation.
  2. Remove deprecated methods in future versions to maintain a clean codebase.
  3. Consider refactoring the class to better separate concerns and improve maintainability.

These suggestions aim to enhance the overall quality and maintainability of the codebase in the long term.


613-615: Improved check for numeric values and zero division.

The modification enhances the validation of input parameters in the get_base_font_size_scale method. It now checks if the $value is numeric and not zero, preventing potential division by zero errors.

This change improves the robustness of the method by adding an additional safety check. It's a good practice to validate input parameters, especially when they're used in mathematical operations.

To ensure this change doesn't introduce any unintended side effects, we should verify its usage across the codebase. Let's run a script to check for any calls to this method:

This will help us identify if there are any places where the method is called with potentially problematic arguments.

✅ Verification successful

Verification Complete: No Issues Found

The updated get_base_font_size_scale method has been successfully verified. The added checks effectively prevent potential division by zero errors, and the method is only called within the FrmStylesHelper.php file, ensuring localized impact.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for calls to get_base_font_size_scale method
rg --type php "get_base_font_size_scale\s*\(" -A 3 -B 3

Length of output: 1116

@Liviu-p Liviu-p self-assigned this Oct 1, 2024
Copy link
Contributor

@Crabcyborg Crabcyborg left a comment

Choose a reason for hiding this comment

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

I haven't tested this yet but it looks good to me.

I tagged Laura for QA as well. I'll merge once she approves.

Thanks @Liviu-p!

🚀

@Crabcyborg
Copy link
Contributor

I'm going to go ahead and merge this. @lauramekaj1 if you do end up finding any issues, feel free to make a new issue in https://github.com/Strategy11/formidable-pro or drop a comment here.

I think this is worth including for tomorrow either way as it shouldn't be introducing issues, but fixes a lot of accessibility issues.

Thank you!

@Crabcyborg
Copy link
Contributor

Oh I commented too soon. I see you left comments in the other PR last week.

Thank you for your feedback @lauramekaj1!

It looks from that list that we're fine to merge this, and then continue making improvements.

@Crabcyborg Crabcyborg merged commit b83d608 into master Oct 22, 2024
16 checks passed
@Crabcyborg Crabcyborg deleted the issue-fixes/ff-style branch October 22, 2024 12:37
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.

2 participants