Skip to content

Commit c3a4e8b

Browse files
committed
Administration: A11y: Replace placeholders with visible labels.
Add visible labels to inputs that are using placeholder attributes as a substitute for visible labeling. Labels added or made visible on the customizer theme search, customizer widget search, customizer menu item search, customizer new page UI, the search plugins screens, the media search screens, and the classic editor link inserter. Props afercia, joedolson, rcreators, sabernhardt. See #40331. git-svn-id: https://develop.svn.wordpress.org/trunk@58146 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 5dff70b commit c3a4e8b

18 files changed

Lines changed: 192 additions & 139 deletions

src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,19 @@
5656
renderHtml: function() {
5757
return (
5858
'<div id="' + this._id + '" class="wp-link-input">' +
59-
'<input type="text" value="" placeholder="' + tinymce.translate( 'Paste URL or type to search' ) + '" />' +
59+
'<label for="' + this._id + '_label">' + tinymce.translate( 'Paste URL or type to search' ) + '</label><input id="' + this._id + '_label" type="text" value="" />' +
6060
'<input type="text" style="display:none" value="" />' +
6161
'</div>'
6262
);
6363
},
6464
setURL: function( url ) {
65-
this.getEl().firstChild.value = url;
65+
this.getEl().firstChild.nextSibling.value = url;
6666
},
6767
getURL: function() {
68-
return tinymce.trim( this.getEl().firstChild.value );
68+
return tinymce.trim( this.getEl().firstChild.nextSibling.value );
6969
},
7070
getLinkText: function() {
71-
var text = this.getEl().firstChild.nextSibling.value;
71+
var text = this.getEl().firstChild.nextSibling.nextSibling.value;
7272

7373
if ( ! tinymce.trim( text ) ) {
7474
return '';
@@ -77,7 +77,7 @@
7777
return text.replace( /[\r\n\t ]+/g, ' ' );
7878
},
7979
reset: function() {
80-
var urlInput = this.getEl().firstChild;
80+
var urlInput = this.getEl().firstChild.nextSibling;
8181

8282
urlInput.value = '';
8383
urlInput.nextSibling.value = '';
@@ -394,7 +394,7 @@
394394
type: 'WPLinkInput',
395395
onPostRender: function() {
396396
var element = this.getEl(),
397-
input = element.firstChild,
397+
input = element.firstChild.nextSibling,
398398
$input, cache, last;
399399

400400
inputInstance = this;
@@ -438,7 +438,7 @@
438438
},
439439
select: function( event, ui ) {
440440
$input.val( ui.item.permalink );
441-
$( element.firstChild.nextSibling ).val( ui.item.title );
441+
$( element.firstChild.nextSibling.nextSibling ).val( ui.item.title );
442442

443443
if ( 9 === event.keyCode && typeof window.wpLinkL10n !== 'undefined' ) {
444444
// Audible confirmation message when a link has been selected.

src/js/_enqueues/wp/customize/controls.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,7 +1917,7 @@
19171917
section.contentContainer.on( 'click', '.feature-filter-toggle', function( e ) {
19181918
var $themeContainer = $( '.customize-themes-full-container' ),
19191919
$filterToggle = $( e.currentTarget );
1920-
section.filtersHeight = $filterToggle.parent().next( '.filter-drawer' ).height();
1920+
section.filtersHeight = $filterToggle.parents( '.themes-filter-bar' ).next( '.filter-drawer' ).height();
19211921

19221922
if ( 0 < $themeContainer.scrollTop() ) {
19231923
$themeContainer.animate( { scrollTop: 0 }, 400 );
@@ -1932,7 +1932,7 @@
19321932
.attr( 'aria-expanded', function( i, attr ) {
19331933
return 'true' === attr ? 'false' : 'true';
19341934
})
1935-
.parent().next( '.filter-drawer' ).slideToggle( 180, 'linear' );
1935+
.parents( '.themes-filter-bar' ).next( '.filter-drawer' ).slideToggle( 180, 'linear' );
19361936

19371937
if ( $filterToggle.hasClass( 'open' ) ) {
19381938
var marginOffset = 1018 < window.innerWidth ? 50 : 76;
@@ -3739,7 +3739,7 @@
37393739
ready: function() {
37403740
var control = this, newItem;
37413741
if ( 'dropdown-pages' === control.params.type && control.params.allow_addition ) {
3742-
newItem = control.container.find( '.new-content-item' );
3742+
newItem = control.container.find( '.new-content-item-wrapper' );
37433743
newItem.hide(); // Hide in JS to preserve flex display when showing.
37443744
control.container.on( 'click', '.add-new-toggle', function( e ) {
37453745
$( e.currentTarget ).slideUp( 180 );
@@ -4085,7 +4085,7 @@
40854085
}
40864086

40874087
toggle = control.container.find( '.add-new-toggle' );
4088-
container = control.container.find( '.new-content-item' );
4088+
container = control.container.find( '.new-content-item-wrapper' );
40894089
input = control.container.find( '.create-item-input' );
40904090
title = input.val();
40914091
select = control.container.find( 'select' );

src/js/media/views/attachments/browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.pro
378378
}
379379

380380
if ( this.options.search ) {
381-
// Search is an input, a visually hidden label element needs to be rendered before.
381+
// Search is an input, a label element needs to be rendered before.
382382
this.toolbar.set( 'searchLabel', new wp.media.view.Label({
383383
value: l10n.searchLabel,
384384
className: 'media-search-input-label',

src/wp-admin/css/common.css

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,9 @@ th.action-links {
10901090

10911091
.wp-filter .search-form {
10921092
float: right;
1093-
margin: 10px 0;
1093+
display: flex;
1094+
align-items: center;
1095+
column-gap: .5rem;
10941096
}
10951097

10961098
.wp-filter .search-form input[type="search"] {
@@ -1119,7 +1121,6 @@ th.action-links {
11191121
.wp-filter .search-form.search-plugins .wp-filter-search,
11201122
.no-js .wp-filter .search-form.search-plugins .button {
11211123
display: inline-block;
1122-
margin-top: 10px;
11231124
vertical-align: top;
11241125
}
11251126

@@ -1360,6 +1361,11 @@ th.action-links {
13601361
position: relative;
13611362
max-width: 100%;
13621363
}
1364+
.wp-filter .search-form {
1365+
margin: 11px 0;
1366+
flex-wrap: wrap;
1367+
row-gap: 10px;
1368+
}
13631369
}
13641370

13651371
@media only screen and (max-width: 782px) {
@@ -4151,7 +4157,6 @@ img {
41514157
}
41524158

41534159
.wp-filter .search-form input[type="search"] {
4154-
width: 100%;
41554160
font-size: 1rem;
41564161
}
41574162

@@ -4205,6 +4210,10 @@ img {
42054210
.nav-tab-active:focus:active {
42064211
border-bottom: 1px solid #c3c4c7;
42074212
}
4213+
4214+
.wp-filter .search-form.search-plugins label {
4215+
width: 100%;
4216+
}
42084217
}
42094218

42104219
@media screen and (max-width: 480px) {

src/wp-admin/css/customize-controls.css

Lines changed: 76 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,14 +1082,24 @@ p.customize-section-description {
10821082
float: left;
10831083
}
10841084

1085-
#available-menu-items .accordion-section-content .new-content-item,
1086-
.customize-control-dropdown-pages .new-content-item {
1085+
#available-menu-items .accordion-section-content .new-content-item-wrapper,
1086+
.customize-control-dropdown-pages .new-content-item-wrapper {
10871087
width: calc(100% - 30px);
10881088
padding: 8px 15px;
10891089
position: absolute;
10901090
bottom: 0;
10911091
z-index: 10;
10921092
background: #f0f0f1;
1093+
}
1094+
1095+
.customize-control-dropdown-pages .new-content-item-wrapper {
1096+
width: 100%;
1097+
padding: 0;
1098+
position: static;
1099+
}
1100+
1101+
#available-menu-items .accordion-section-content .new-content-item,
1102+
.customize-control-dropdown-pages .new-content-item {
10931103
display: flex;
10941104
}
10951105

@@ -1099,6 +1109,14 @@ p.customize-section-description {
10991109
position: relative;
11001110
}
11011111

1112+
.customize-control-dropdown-pages .new-content-item-wrapper .new-content-item {
1113+
padding: 0;
1114+
}
1115+
1116+
.customize-control-dropdown-pages .new-content-item-wrapper .new-content-item label {
1117+
line-height: 1.6;
1118+
}
1119+
11021120
#available-menu-items .new-content-item .create-item-input,
11031121
.customize-control-dropdown-pages .new-content-item .create-item-input {
11041122
flex-grow: 10;
@@ -1815,11 +1833,6 @@ p.customize-section-description {
18151833
bottom: 0;
18161834
}
18171835

1818-
.themes-filter-bar .feature-filter-toggle {
1819-
float: right;
1820-
margin: 3px 0 3px 25px;
1821-
}
1822-
18231836
.themes-filter-bar .feature-filter-toggle:before {
18241837
content: "\f111";
18251838
margin: 0 5px 0 0;
@@ -1880,12 +1893,6 @@ p.customize-section-description {
18801893
animation: .6s themes-fade-in 1;
18811894
}
18821895

1883-
.control-panel-themes .filter-themes-count {
1884-
position: relative;
1885-
float: right;
1886-
line-height: 2.6;
1887-
}
1888-
18891896
.control-panel-themes .filter-themes-count .themes-displayed {
18901897
font-weight: 600;
18911898
color: #50575e;
@@ -2097,6 +2104,28 @@ p.customize-section-description {
20972104
box-sizing: border-box;
20982105
border-bottom: 1px solid #dcdcde;
20992106
}
2107+
.customize-preview-header.themes-filter-bar,
2108+
.customize-preview-header.themes-filter-bar .search-form {
2109+
display: flex;
2110+
align-items: center;
2111+
gap: 10px;
2112+
flex-wrap: wrap;
2113+
}
2114+
2115+
.customize-preview-header.themes-filter-bar .search-form-input {
2116+
position: relative;
2117+
}
2118+
2119+
.customize-preview-header .filter-themes-wrapper {
2120+
display: grid;
2121+
align-items: center;
2122+
gap: 10px;
2123+
grid-template-columns: auto 1fr;
2124+
}
2125+
2126+
.customize-preview-header .filter-themes-wrapper .filter-themes-count {
2127+
justify-self: end;
2128+
}
21002129

21012130
@media screen and (min-width: 1670px) {
21022131
.customize-preview-header.themes-filter-bar {
@@ -2109,6 +2138,9 @@ p.customize-section-description {
21092138
.themes-filter-bar .themes-filter-container {
21102139
margin: 0;
21112140
padding: 0;
2141+
display: flex;
2142+
align-items: center;
2143+
gap: 10px;
21122144
}
21132145

21142146
.themes-filter-bar .wp-filter-search {
@@ -2117,11 +2149,10 @@ p.customize-section-description {
21172149
max-width: 100%;
21182150
width: 40%;
21192151
min-width: 300px;
2120-
position: absolute;
2121-
top: 6px;
2122-
left: 25px;
21232152
height: 32px;
21242153
margin: 1px 0;
2154+
top: 0;
2155+
left: 0;
21252156
}
21262157

21272158
/* Unstick the filter bar on short windows/screens. This breakpoint is based on the
@@ -2155,18 +2186,31 @@ p.customize-section-description {
21552186
}
21562187
}
21572188

2158-
@media screen and (max-width: 900px) {
2189+
@media screen and (max-width: 960px) {
21592190
.customize-preview-header.themes-filter-bar {
2160-
height: 86px;
2161-
padding-top: 46px;
2191+
height: 96px;
21622192
}
2193+
}
21632194

2195+
@media screen and (max-width: 900px) {
21642196
.themes-filter-bar .wp-filter-search {
2165-
width: calc(100% - 50px);
2197+
width: 100%;
21662198
margin: 0;
21672199
min-width: 200px;
21682200
}
21692201

2202+
.customize-preview-header.themes-filter-bar,
2203+
.customize-preview-header.themes-filter-bar .search-form
2204+
.themes-filter-bar .themes-filter-container {
2205+
display: grid;
2206+
gap: 4px;
2207+
}
2208+
2209+
.customize-preview-header.themes-filter-bar .search-form-input {
2210+
display: flex;
2211+
flex-grow: 1;
2212+
}
2213+
21702214
.filter-drawer {
21712215
top: 86px;
21722216
}
@@ -2580,7 +2624,7 @@ body.adding-widget .add-new-widget:before,
25802624
}
25812625

25822626
#available-widgets-list {
2583-
top: 60px;
2627+
top: 82px;
25842628
position: absolute;
25852629
overflow: auto;
25862630
bottom: 0;
@@ -2624,7 +2668,7 @@ body.adding-widget .add-new-widget:before,
26242668
#available-widgets-filter .search-icon {
26252669
display: block;
26262670
position: absolute;
2627-
top: 15px; /* 13 container padding +1 input margin +1 input border */
2671+
bottom: 15px; /* 13 container padding +1 input margin +1 input border */
26282672
left: 16px;
26292673
width: 30px;
26302674
height: 30px;
@@ -2634,9 +2678,9 @@ body.adding-widget .add-new-widget:before,
26342678
}
26352679

26362680
#available-widgets-filter .clear-results,
2637-
#available-menu-items-search .clear-results {
2681+
#available-menu-items-search .accordion-section-title .clear-results {
26382682
position: absolute;
2639-
top: 15px; /* 13 container padding +1 input margin +1 input border */
2683+
top: 36px; /* 13 container padding +1 input margin +1 input border */
26402684
right: 16px;
26412685
width: 30px;
26422686
height: 30px;
@@ -2695,8 +2739,8 @@ body.adding-widget .add-new-widget:before,
26952739

26962740
.themes-filter-bar .search-icon {
26972741
position: absolute;
2698-
top: 7px;
2699-
left: 26px;
2742+
top: 2px;
2743+
left: 2px;
27002744
z-index: 1;
27012745
color: #646970;
27022746
height: 30px;
@@ -2814,8 +2858,8 @@ body.adding-widget .add-new-widget:before,
28142858
margin-top: 12px;
28152859
}
28162860

2817-
.wp-core-ui .themes-filter-bar .feature-filter-toggle {
2818-
margin: 3px 0 3px 25px;
2861+
.customize-preview-header.themes-filter-bar .search-icon {
2862+
top: 6px;
28192863
}
28202864
}
28212865

@@ -2952,22 +2996,18 @@ body.adding-widget .add-new-widget:before,
29522996
}
29532997

29542998
#available-widgets-list {
2955-
top: 130px;
2999+
top: 152px;
29563000
}
29573001

2958-
#available-menu-items-search .clear-results,
2959-
#available-menu-items-search .search-icon {
2960-
top: 85px; /* 70 section title height + 13 container padding +1 input margin +1 input border */
3002+
#available-menu-items-search .clear-results {
3003+
top: 36px;
3004+
right: 16px;
29613005
}
29623006

29633007
.reorder,
29643008
.reordering .reorder-done {
29653009
padding: 8px;
29663010
}
2967-
2968-
.wp-core-ui .themes-filter-bar .feature-filter-toggle {
2969-
margin: 0;
2970-
}
29713011
}
29723012

29733013
@media screen and (max-width: 600px) {

0 commit comments

Comments
 (0)