-
Notifications
You must be signed in to change notification settings - Fork 41
Improve accessibility of slider setting #3091
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,29 @@ | ||
| <?php if ( ! defined( 'ABSPATH' ) ) { | ||
| <?php | ||
| /** | ||
| * Slider style component template. | ||
| * | ||
| * @since 6.14 | ||
| * | ||
| * @package Formidable | ||
| * | ||
| * @var string $component_attr HTML attribute string for the outer wrapper element. | ||
| * @var string $component_class CSS class string for the outer wrapper element. | ||
| * @var array $component Slider configuration data set by FrmSliderStyleComponent. | ||
| * @var string $field_name HTML name attribute string (e.g. 'name="frm_style_setting[post_content][font_size]"'). | ||
| * @var string $field_value Raw field value including unit (e.g. '13px' or '10px 20px 10px 20px'). | ||
| */ | ||
|
|
||
| if ( ! defined( 'ABSPATH' ) ) { | ||
| die( 'You are not allowed to call this page directly.' ); | ||
| } | ||
|
|
||
| if ( $component['has-multiple-values'] ) : ?> | ||
| if ( ! empty( $component['has-multiple-values'] ) ) : ?> | ||
| <div class="<?php echo esc_attr( $component_class ); ?>" <?php echo esc_attr( $component_attr ); ?> > | ||
| <div class="frm-slider-component frm-has-multiple-values frm-group-sliders" data-display-sliders="top,bottom" data-type="vertical" data-max-value="<?php echo (int) $component['max_value']; ?>"> | ||
| <div class="frm-flex-justify"> | ||
| <div class="frm-slider-container"> | ||
| <?php FrmAppHelper::icon_by_class( 'frmfont frm-margin-top-bottom' ); ?> | ||
| <span class="frm-slider" tabindex="0"> | ||
| <span class="frm-slider-active-track"> | ||
| <span class="frm-slider-bullet"> | ||
| <span class="frm-slider-value-label"><?php echo (int) $component['vertical']['value']; ?></span> | ||
| </span> | ||
| </span> | ||
| </span> | ||
| <input type="range" class="frm-slider" min="0" max="<?php echo (int) $component['max_value']; ?>" value="<?php echo esc_attr( $component['vertical']['value'] ); ?>" /> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add an accessible name to each range input. These sliders are now native controls, but they still render without a label. Screen readers will announce an unnamed slider here because only the sibling text input/select has Representative fix-<input type="range" class="frm-slider" min="0" max="<?php echo (int) $component['max_value']; ?>" value="<?php echo esc_attr( $component['vertical']['value'] ); ?>" />
+<input
+ aria-label="<?php esc_attr_e( 'Vertical value', 'formidable' ); ?>"
+ type="range"
+ class="frm-slider"
+ min="0"
+ max="<?php echo (int) $component['max_value']; ?>"
+ value="<?php echo esc_attr( $component['vertical']['value'] ); ?>"
+/>Apply the same pattern to the other range inputs in this template. Also applies to: 27-27, 43-43, 59-59, 75-75, 91-91, 114-114, 133-133, 154-154 🤖 Prompt for AI Agents |
||
| </div> | ||
| <div class="frm-slider-value"> | ||
| <input aria-label="<?php esc_attr_e( 'Vertical value', 'formidable' ); ?>" type="text" value="<?php echo esc_attr( $component['vertical']['value'] ); ?>" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
@@ -30,13 +39,7 @@ | |
| <div class="frm-flex-justify"> | ||
| <div class="frm-slider-container"> | ||
| <?php FrmAppHelper::icon_by_class( 'frmfont frm-margin-top' ); ?> | ||
| <span class="frm-slider" tabindex="0"> | ||
| <span class="frm-slider-active-track"> | ||
| <span class="frm-slider-bullet"> | ||
| <span class="frm-slider-value-label"><?php echo (int) $component['top']['value']; ?></span> | ||
| </span> | ||
| </span> | ||
| </span> | ||
| <input type="range" class="frm-slider" min="0" max="<?php echo (int) $component['max_value']; ?>" value="<?php echo esc_attr( $component['top']['value'] ); ?>" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| </div> | ||
| <div class="frm-slider-value"> | ||
| <input aria-label="<?php esc_attr_e( 'Top value', 'formidable' ); ?>" type="text" value="<?php echo esc_attr( $component['top']['value'] ); ?>" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
@@ -52,13 +55,7 @@ | |
| <div class="frm-flex-justify"> | ||
| <div class="frm-slider-container"> | ||
| <?php FrmAppHelper::icon_by_class( 'frmfont frm-margin-bottom' ); ?> | ||
| <span class="frm-slider" tabindex="0"> | ||
| <span class="frm-slider-active-track"> | ||
| <span class="frm-slider-bullet"> | ||
| <span class="frm-slider-value-label"><?php echo (int) $component['bottom']['value']; ?></span> | ||
| </span> | ||
| </span> | ||
| </span> | ||
| <input type="range" class="frm-slider" min="0" max="<?php echo (int) $component['max_value']; ?>" value="<?php echo esc_attr( $component['bottom']['value'] ); ?>" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| </div> | ||
| <div class="frm-slider-value"> | ||
| <input aria-label="<?php esc_attr_e( 'Bottom value', 'formidable' ); ?>" type="text" value="<?php echo esc_attr( $component['bottom']['value'] ); ?>" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
@@ -74,13 +71,7 @@ | |
| <div class="frm-flex-justify"> | ||
| <div class="frm-slider-container"> | ||
| <?php FrmAppHelper::icon_by_class( 'frmfont frm-margin-left-right' ); ?> | ||
| <span class="frm-slider" tabindex="0"> | ||
| <span class="frm-slider-active-track"> | ||
| <span class="frm-slider-bullet"> | ||
| <span class="frm-slider-value-label"><?php echo (int) $component['horizontal']['value']; ?></span> | ||
| </span> | ||
| </span> | ||
| </span> | ||
| <input type="range" class="frm-slider" min="0" max="<?php echo (int) $component['max_value']; ?>" value="<?php echo esc_attr( $component['horizontal']['value'] ); ?>" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| </div> | ||
| <div class="frm-slider-value"> | ||
| <input aria-label="<?php esc_attr_e( 'Horizontal value', 'formidable' ); ?>" type="text" value="<?php echo esc_attr( $component['horizontal']['value'] ); ?>" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
@@ -96,13 +87,7 @@ | |
| <div class="frm-flex-justify"> | ||
| <div class="frm-slider-container"> | ||
| <?php FrmAppHelper::icon_by_class( 'frmfont frm-margin-left' ); ?> | ||
| <span class="frm-slider" tabindex="0"> | ||
| <span class="frm-slider-active-track"> | ||
| <span class="frm-slider-bullet"> | ||
| <span class="frm-slider-value-label"><?php echo (int) $component['left']['value']; ?></span> | ||
| </span> | ||
| </span> | ||
| </span> | ||
| <input type="range" class="frm-slider" min="0" max="<?php echo (int) $component['max_value']; ?>" value="<?php echo esc_attr( $component['left']['value'] ); ?>" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| </div> | ||
| <div class="frm-slider-value"> | ||
| <input aria-label="<?php esc_attr_e( 'Left value', 'formidable' ); ?>" type="text" value="<?php echo esc_attr( $component['left']['value'] ); ?>" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
@@ -118,13 +103,7 @@ | |
| <div class="frm-flex-justify"> | ||
| <div class="frm-slider-container"> | ||
| <?php FrmAppHelper::icon_by_class( 'frmfont frm-margin-right' ); ?> | ||
| <span class="frm-slider" tabindex="0"> | ||
| <span class="frm-slider-active-track"> | ||
| <span class="frm-slider-bullet"> | ||
| <span class="frm-slider-value-label"><?php echo (int) $component['right']['value']; ?></span> | ||
| </span> | ||
| </span> | ||
| </span> | ||
| <input type="range" class="frm-slider" min="0" max="<?php echo (int) $component['max_value']; ?>" value="<?php echo esc_attr( $component['right']['value'] ); ?>" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| </div> | ||
| <div class="frm-slider-value"> | ||
| <input aria-label="<?php esc_attr_e( 'Right value', 'formidable' ); ?>" type="text" value="<?php echo esc_attr( $component['right']['value'] ); ?>" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
@@ -147,13 +126,7 @@ | |
| <?php if ( ! empty( $component['icon'] ) ) : ?> | ||
| <?php FrmAppHelper::icon_by_class( $component['icon'] ); ?> | ||
| <?php endif; ?> | ||
| <span class="frm-slider" tabindex="0"> | ||
| <span class="frm-slider-active-track"> | ||
| <span class="frm-slider-bullet"> | ||
| <span class="frm-slider-value-label"><?php echo (int) $field_value; ?></span> | ||
| </span> | ||
| </span> | ||
| </span> | ||
| <input type="range" class="frm-slider" min="0" max="<?php echo (int) $component['max_value']; ?>" value="<?php echo esc_attr( $component['value_label'] ); ?>" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| </div> | ||
| <div class="frm-slider-value"> | ||
| <input aria-label="<?php esc_attr_e( 'Field value', 'formidable' ); ?>" type="text" value="<?php echo esc_attr( $component['value_label'] ); ?>" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
@@ -172,13 +145,7 @@ | |
| <div class="frm-flex-justify"> | ||
| <div class="frm-slider-container"> | ||
| <?php FrmAppHelper::icon_by_class( 'frmfont frm-margin-top-bottom' ); ?> | ||
| <span class="frm-slider" tabindex="0"> | ||
| <span class="frm-slider-active-track"> | ||
| <span class="frm-slider-bullet"> | ||
| <span class="frm-slider-value-label"><?php echo (int) $field_value; ?></span> | ||
| </span> | ||
| </span> | ||
| </span> | ||
| <input type="range" class="frm-slider" min="0" max="<?php echo (int) $component['max_value']; ?>" value="<?php echo esc_attr( $component['value_label'] ); ?>" /> | ||
| </div> | ||
| <div class="frm-slider-value"> | ||
| <input aria-label="<?php esc_attr_e( 'Field value', 'formidable' ); ?>" type="text" value="<?php echo esc_attr( $component['value_label'] ); ?>" /> | ||
|
|
@@ -199,13 +166,7 @@ | |
| <?php if ( ! empty( $component['icon'] ) ) : ?> | ||
| <?php FrmAppHelper::icon_by_class( 'frmfont frm-margin-' . $field['type'] ); ?> | ||
| <?php endif; ?> | ||
| <span class="frm-slider" tabindex="0"> | ||
| <span class="frm-slider-active-track"> | ||
| <span class="frm-slider-bullet"> | ||
| <span class="frm-slider-value-label"><?php echo (int) $field['value']; ?></span> | ||
| </span> | ||
| </span> | ||
| </span> | ||
| <input type="range" class="frm-slider" min="0" max="<?php echo (int) $component['max_value']; ?>" value="<?php echo ! empty( $component['unit_measurement'] ) ? (int) $field['value'] : esc_attr( $field['value'] ); ?>" /> | ||
| </div> | ||
| <div class="frm-slider-value"> | ||
| <input aria-label="<?php esc_attr_e( 'Field value', 'formidable' ); ?>" type="text" value="<?php echo ! empty( $component['unit_measurement'] ) ? (int) $field['value'] : esc_attr( $field['value'] ); ?>" /> | ||
|
|
@@ -223,4 +184,4 @@ | |
| </div> | ||
| <?php endif; ?> | ||
| </div> | ||
| <?php endif; ?> | ||
| <?php endif; ?> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.