Skip to content

Commit 99944bd

Browse files
fix: enhance tooltip accessibility for checkbox options
1 parent b5e393a commit 99944bd

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

templates/frontend/inputs/checkbox.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,22 @@ class="<?php echo esc_attr( $input_class ); ?>"
148148

149149

150150
<span class="ppom-input-option-label ppom-label-checkbox"><?php echo $option_label; ?>
151-
<?php if ( $is_tooltip_enabled && ! empty( $option_tooltip ) ) : ?>
152-
<span data-ppom-tooltip="ppom_tooltip" class="ppom-tooltip" title="<?php echo esc_attr( $option_tooltip ); ?>"><span class="ppom-tooltip-icon" style="background-color:<?php echo esc_attr( $icon_color ); ?>;"></span></span>
151+
<?php
152+
if ( $is_tooltip_enabled && ! empty( $option_tooltip ) ) :
153+
$tooltip_description_id = esc_attr( $dom_id . '-tooltip-description' );
154+
?>
155+
<span
156+
data-ppom-tooltip="ppom_tooltip"
157+
class="ppom-tooltip"
158+
title="<?php echo esc_attr( $option_tooltip ); ?>"
159+
tabindex="0"
160+
role="button"
161+
aria-label="<?php echo wp_strip_all_tags( $raw_label ); ?>"
162+
aria-describedby="<?php echo $tooltip_description_id; ?>"
163+
>
164+
<span class="ppom-tooltip-icon" style="background-color:<?php echo esc_attr( $icon_color ); ?>;"></span>
165+
</span>
166+
<span id="<?php echo $tooltip_description_id; ?>" class="screen-reader-text"><?php echo esc_html( $option_tooltip ); ?></span>
153167
<?php endif; ?>
154168
</span>
155169
</label>

0 commit comments

Comments
 (0)