Make WordPress Core


Ignore:
Timestamp:
07/16/2025 10:50:07 PM (9 months ago)
Author:
joedolson
Message:

Customize: Use explicit labels in hue picker.

Add for and id attributes to the customizer hue picker, so labels are explicitly associated. Move picker outside of label element. Add label value for Twenty Seventeen, Twenty Nineteen, and Twenty Twenty.

Props afercia, subrataemfluence, dlh, jorbin, sainathpoojary, abcd95, mleraygp, joedolson.
Fixes #42078.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/customize/class-wp-customize-color-control.php

    r47382 r60478  
    9393    public function content_template() {
    9494        ?>
    95         <# var defaultValue = '#RRGGBB', defaultValueAttr = '',
     95        <#
     96        var defaultValue = '#RRGGBB',
     97            defaultValueAttr = '',
     98            inputId = _.uniqueId( 'customize-color-control-input-' ),
    9699            isHueSlider = data.mode === 'hue';
     100
    97101        if ( data.defaultValue && _.isString( data.defaultValue ) && ! isHueSlider ) {
    98102            if ( '#' !== data.defaultValue.substring( 0, 1 ) ) {
     
    102106            }
    103107            defaultValueAttr = ' data-default-color=' + defaultValue; // Quotes added automatically.
    104         } #>
     108        }
     109        #>
    105110        <# if ( data.label ) { #>
    106111            <span class="customize-control-title">{{{ data.label }}}</span>
     
    110115        <# } #>
    111116        <div class="customize-control-content">
    112             <label><span class="screen-reader-text">{{{ data.label }}}</span>
     117            <label for="{{ inputId }}"><span class="screen-reader-text">{{{ data.label }}}</span></label>
    113118            <# if ( isHueSlider ) { #>
    114                 <input class="color-picker-hue" type="text" data-type="hue" />
     119                <input id="{{ inputId }}" class="color-picker-hue" type="number" min="1" max="359" data-type="hue" />
    115120            <# } else { #>
    116                 <input class="color-picker-hex" type="text" maxlength="7" placeholder="{{ defaultValue }}" {{ defaultValueAttr }} />
     121                <input id="{{ inputId }}" class="color-picker-hex" type="text" maxlength="7" placeholder="{{ defaultValue }}" {{ defaultValueAttr }} />
    117122            <# } #>
    118             </label>
    119123        </div>
    120124        <?php
Note: See TracChangeset for help on using the changeset viewer.