Changeset 62878
- Timestamp:
- 07/28/2026 08:05:34 PM (4 months ago)
- Location:
- trunk
- Files:
-
- 9 edited
-
src/js/_enqueues/wp/customize/controls.js (modified) (6 diffs)
-
src/js/_enqueues/wp/theme.js (modified) (12 diffs)
-
src/js/media/views/frame/edit-attachments.js (modified) (6 diffs)
-
src/wp-admin/theme-install.php (modified) (1 diff)
-
src/wp-admin/themes.php (modified) (2 diffs)
-
src/wp-admin/upload.php (modified) (1 diff)
-
src/wp-includes/class-wp-customize-manager.php (modified) (1 diff)
-
src/wp-includes/media.php (modified) (1 diff)
-
tests/qunit/wp-admin/js/theme.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/wp/customize/controls.js
r62431 r62878 1702 1702 headerContainer: null, 1703 1703 updateCountDebounced: null, 1704 announceThemeDebounced: null, 1704 1705 1705 1706 /** … … 1725 1726 api.Section.prototype.initialize.call( section, id, options ); 1726 1727 section.updateCountDebounced = _.debounce( section.updateCount, 500 ); 1728 section.announceThemeDebounced = _.debounce( function( name ) { 1729 if ( ! name ) { 1730 return; 1731 } 1732 1733 wp.a11y.speak( api.settings.l10n.announceThemeDetails.replace( '%s', name ) ); 1734 }, 500 ); 1727 1735 }, 1728 1736 … … 1778 1786 } 1779 1787 1788 // Require the alt key for arrow events. 1789 if ( 27 !== event.keyCode && ! event.altKey ) { 1790 return; 1791 } 1792 1780 1793 // Pressing the right arrow key fires a theme:next event. 1781 1794 if ( 39 === event.keyCode ) { 1795 event.preventDefault(); // Prevent browser from triggering history shortcuts. 1782 1796 section.nextTheme(); 1783 1797 } … … 1785 1799 // Pressing the left arrow key fires a theme:previous event. 1786 1800 if ( 37 === event.keyCode ) { 1801 event.preventDefault(); // Prevent browser from triggering history shortcuts. 1787 1802 section.previousTheme(); 1788 1803 } … … 2603 2618 section.containFocus( section.overlay ); 2604 2619 section.updateLimits(); 2605 wp.a11y.speak( api.settings.l10n.announceThemeDetails.replace( '%s', theme.name ) ); 2620 2621 section.announceThemeDebounced( theme.name ); 2606 2622 if ( callback ) { 2607 2623 callback(); … … 2621 2637 section.overlay.fadeOut( 'fast' ); 2622 2638 api.control( section.params.action + '_theme_' + section.currentTheme ).container.find( '.theme' ).focus(); 2639 // Cancel any pending navigation announcement. 2640 section.announceThemeDebounced.cancel(); 2623 2641 }, 2624 2642 -
trunk/src/js/_enqueues/wp/theme.js
r62869 r62878 16 16 themes.data = _wpThemeSettings; 17 17 l10n = themes.data.l10n; 18 19 /** 20 * Announces to screen readers the theme shown after previous/next navigation. 21 * 22 * @since 7.1.0 23 * 24 * @param {Object} model The theme model. 25 * @return {void} 26 */ 27 themes.announceThemeDebounced = _.debounce( function( model ) { 28 var name; 29 30 if ( ! model ) { 31 return; 32 } 33 34 name = model.get( 'name' ) || model.get( 'id' ); 35 36 if ( ! name ) { 37 return; 38 } 39 40 wp.a11y.speak( l10n.themeViewed.replace( '%s', name ) ); 41 }, 500 ); 18 42 19 43 // Shortcut for isInstall check. … … 550 574 this.setNavButtonsState(); 551 575 $( '.next-theme' ).trigger( 'focus' ); 576 themes.announceThemeDebounced( self.current ); 552 577 }) 553 578 .listenTo( preview, 'theme:previous', function() { … … 580 605 this.setNavButtonsState(); 581 606 $( '.previous-theme' ).trigger( 'focus' ); 607 themes.announceThemeDebounced( self.current ); 582 608 }); 583 609 … … 770 796 }); 771 797 } 798 799 // Cancel any pending navigation announcement. 800 themes.announceThemeDebounced.cancel(); 772 801 }, 773 802 … … 910 939 'click .previous-theme': 'previousTheme', 911 940 'click .next-theme': 'nextTheme', 912 'key up': 'keyEvent',941 'keydown': 'keyEvent', 913 942 'click .theme-install': 'installTheme' 914 943 }, … … 968 997 this.undelegateEvents(); 969 998 this.unbind(); 999 1000 // Cancel any pending navigation announcement. 1001 themes.announceThemeDebounced.cancel(); 970 1002 return false; 971 1003 }, … … 1013 1045 } 1014 1046 1015 // Return if Ctrl + Shift or Shift key pressed1016 if ( event.shiftKey || ( event.ctrlKey && event.shiftKey )) {1047 // Arrow key navigation requires Alt key to avoid interfering with screen reader navigation. 1048 if ( ! event.altKey ) { 1017 1049 return; 1018 1050 } … … 1020 1052 // The right arrow key, next theme. 1021 1053 if ( event.keyCode === 39 ) { 1022 _.once( this.nextTheme() ); 1054 event.preventDefault(); 1055 this.nextTheme(); 1023 1056 } 1024 1057 1025 1058 // The left arrow key, previous theme. 1026 1059 if ( event.keyCode === 37 ) { 1060 event.preventDefault(); 1027 1061 this.previousTheme(); 1028 1062 } … … 1112 1146 1113 1147 // Bind keyboard events. 1114 $( 'body' ).on( 'key up', function( event ) {1148 $( 'body' ).on( 'keydown.wp-themes', function( event ) { 1115 1149 if ( ! self.overlay ) { 1116 1150 return; … … 1122 1156 } 1123 1157 1124 // Return if Ctrl + Shift or Shift key pressed1125 if ( event.shiftKey || ( event.ctrlKey && event.shiftKey ) ) {1126 return;1127 }1128 1129 // Pressing the right arrow key fires a theme:next event.1130 if ( event.keyCode === 39 ) {1131 self.overlay.nextTheme();1132 }1133 1134 // Pressing the left arrow key fires a theme:previous event.1135 if ( event.keyCode === 37 ) {1136 self.overlay.previousTheme();1137 }1138 1139 1158 // Pressing the escape key fires a theme:collapse event. 1140 1159 if ( event.keyCode === 27 ) { 1141 1160 self.overlay.collapse( event ); 1161 } 1162 1163 // Arrow key navigation requires Alt key to avoid interfering with screen reader navigation. 1164 if ( ! event.altKey ) { 1165 return; 1166 } 1167 1168 // Pressing Alt + right arrow key fires a theme:next event. 1169 if ( event.keyCode === 39 ) { 1170 event.preventDefault(); 1171 self.overlay.nextTheme(); 1172 } 1173 1174 // Pressing Alt + left arrow key fires a theme:previous event. 1175 if ( event.keyCode === 37 ) { 1176 event.preventDefault(); 1177 self.overlay.previousTheme(); 1142 1178 } 1143 1179 }); … … 1323 1359 // Trigger a route update for the current model. 1324 1360 self.theme.trigger( 'theme:expand', nextModel.cid ); 1325 1361 themes.announceThemeDebounced( nextModel ); 1326 1362 } 1327 1363 }, … … 1358 1394 // Trigger a route update for the current model. 1359 1395 self.theme.trigger( 'theme:expand', previousModel.cid ); 1360 1396 themes.announceThemeDebounced( previousModel ); 1361 1397 } 1362 1398 }, -
trunk/src/js/media/views/frame/edit-attachments.js
r60516 r62878 1 1 var Frame = wp.media.view.Frame, 2 2 MediaFrame = wp.media.view.MediaFrame, 3 l10n = wp.media.view.l10n, 3 4 4 5 $ = jQuery, … … 34 35 }, 35 36 37 /** 38 * Announces to screen readers the attachment shown after previous/next navigation. 39 * 40 * @since 7.1.0 41 * 42 * @param {Object} model The attachment model. 43 * @return {void} 44 */ 45 announceMediaItemDebounced: _.debounce( function( model ) { 46 var title; 47 48 if ( ! model ) { 49 return; 50 } 51 52 title = model.get( 'title' ) || model.get( 'filename' ) || model.get( 'id' ); 53 54 if ( ! title ) { 55 return; 56 } 57 58 wp.a11y.speak( l10n.mediaItemViewed.replace( '%s', title ) ); 59 }, 500 ), 60 36 61 initialize: function() { 37 62 Frame.prototype.initialize.apply( this, arguments ); … … 97 122 $( 'li.attachment[data-id="' + this.model.get( 'id' ) +'"]' ).trigger( 'focus' ); 98 123 this.resetRoute(); 124 // Cancel any pending navigation announcement. 125 this.announceMediaItemDebounced.cancel(); 99 126 }, this ) ); 100 127 … … 203 230 */ 204 231 previousMediaItem: function() { 232 var model; 233 205 234 if ( ! this.hasPrevious() ) { 206 235 return; 207 236 } 208 237 209 this.trigger( 'refresh', this.library.at( this.getCurrentIndex() - 1 ) ); 238 model = this.library.at( this.getCurrentIndex() - 1 ); 239 this.trigger( 'refresh', model ); 210 240 // Move focus to the Previous button. When there are no more items, to the Next button. 211 241 this.focusNavButton( this.hasPrevious() ? '.left' : '.right' ); 242 this.announceMediaItemDebounced( model ); 212 243 }, 213 244 … … 216 247 */ 217 248 nextMediaItem: function() { 249 var model; 250 218 251 if ( ! this.hasNext() ) { 219 252 return; 220 253 } 221 254 222 this.trigger( 'refresh', this.library.at( this.getCurrentIndex() + 1 ) ); 255 model = this.library.at( this.getCurrentIndex() + 1 ); 256 this.trigger( 'refresh', model ); 223 257 // Move focus to the Next button. When there are no more items, to the Previous button. 224 258 this.focusNavButton( this.hasNext() ? '.right' : '.left' ); 259 this.announceMediaItemDebounced( model ); 225 260 }, 226 261 … … 248 283 }, 249 284 /** 250 * Respond to the keyboard events: right arrow, left arrow, except when 251 * focus is in a textarea or input field. 285 * Respond to the keyboard events: Alt + right arrow, Alt + left arrow, 286 * except when focus is in a form field. Requires the Alt modifier key to 287 * avoid interfering with screen reader navigation. 252 288 */ 253 289 keyEvent: function( event ) { 254 if ( ( 'INPUT' === event.target.nodeName || 'TEXTAREA' === event.target.nodeName ) && ! event.target.disabled ) {255 return; 256 } 257 258 // Return if Ctrl + Shift or Shift key pressed259 if ( event.shiftKey || ( event.ctrlKey && event.shiftKey )) {260 return; 261 } 262 263 // Theright arrow key.290 if ( ( 'INPUT' === event.target.nodeName || 'TEXTAREA' === event.target.nodeName || 'SELECT' === event.target.nodeName ) && ! event.target.disabled ) { 291 return; 292 } 293 294 // Arrow key navigation requires Alt key to avoid interfering with screen reader navigation. 295 if ( ! event.altKey ) { 296 return; 297 } 298 299 // Alt + right arrow key. 264 300 if ( 39 === event.keyCode ) { 301 event.preventDefault(); 265 302 this.nextMediaItem(); 266 303 } 267 // Theleft arrow key.304 // Alt + left arrow key. 268 305 if ( 37 === event.keyCode ) { 306 event.preventDefault(); 269 307 this.previousMediaItem(); 270 308 } -
trunk/src/wp-admin/theme-install.php
r62516 r62878 68 68 'themesFound' => __( 'Number of Themes found: %d' ), 69 69 'noThemesFound' => __( 'No themes found. Try a different search.' ), 70 /* translators: %s: Theme name. */ 71 'themeViewed' => __( 'Theme details: %s' ), 70 72 'collapseSidebar' => __( 'Collapse Sidebar' ), 71 73 'expandSidebar' => __( 'Expand Sidebar' ), -
trunk/src/wp-admin/themes.php
r62516 r62878 132 132 $help_overview = '<p>' . __( 'This screen is used for managing your installed themes. Aside from the default theme(s) included with your WordPress installation, themes are designed and developed by third parties.' ) . '</p>' . 133 133 '<p>' . __( 'From this screen you can:' ) . '</p>' . 134 '<ul><li>' . __( 'Hover or tap to see Activate and Live Preview buttons' ) . '</li>' . 135 '<li>' . __( 'Click on the theme to see the theme name, version, author, description, tags, and the Delete link' ) . '</li>' . 136 '<li>' . __( 'Click Customize for the active theme or Live Preview for any other theme to see a live preview' ) . '</li></ul>' . 134 '<ul><li>' . __( 'Hover or tap to see Activate and Live Preview buttons.' ) . '</li>' . 135 '<li>' . __( 'Click Customize for the active theme or Live Preview for any other theme to see a live preview.' ) . '</li>' . 136 '<li>' . __( 'Click on a theme to open the Theme Details dialog and see the theme name, version, author, description, tags, and the Delete link.' ) . '</li>' . 137 '<li>' . __( 'Use the buttons at the top of the dialog, or <code>alt</code>/<code>option</code> plus the left or right arrow keys on your keyboard, to navigate between themes quickly.' ) . '</li></ul>' . 137 138 '<p>' . __( 'The active theme is displayed highlighted as the first theme.' ) . '</p>' . 138 139 '<p>' . __( 'The search for installed themes will search for terms in their name, description, author, or tag.' ) . ' <span id="live-search-desc">' . __( 'The search results will be updated as you type.' ) . '</span></p>'; … … 237 238 'themesFound' => __( 'Number of Themes found: %d' ), 238 239 'noThemesFound' => __( 'No themes found. Try a different search.' ), 240 /* translators: %s: Theme name. */ 241 'themeViewed' => __( 'Theme details: %s' ), 239 242 ), 240 243 ) -
trunk/src/wp-admin/upload.php
r61453 r62878 191 191 'content' => 192 192 '<p>' . __( 'Clicking an item will display an Attachment Details dialog, which allows you to preview media and make quick edits. Any changes you make to the attachment details will be automatically saved.' ) . '</p>' . 193 '<p>' . __( 'Use the arrow buttons at the top of the dialog, or the left andright arrow keys on your keyboard, to navigate between media items quickly.' ) . '</p>' .193 '<p>' . __( 'Use the buttons at the top of the dialog, or <code>alt</code>/<code>option</code> plus the left or right arrow keys on your keyboard, to navigate between media items quickly.' ) . '</p>' . 194 194 '<p>' . __( 'You can also delete individual items and access the extended edit screen from the details dialog.' ) . '</p>', 195 195 ) -
trunk/src/wp-includes/class-wp-customize-manager.php
r62763 r62878 4960 4960 'announceThemeCount' => __( 'Displaying %d themes' ), 4961 4961 /* translators: %s: Theme name. */ 4962 'announceThemeDetails' => __( ' Showing details for theme: %s' ),4962 'announceThemeDetails' => __( 'Theme details: %s' ), 4963 4963 ), 4964 4964 ); -
trunk/src/wp-includes/media.php
r62807 r62878 5190 5190 'noMedia' => __( 'No media items found.' ), 5191 5191 'noMediaTryNewSearch' => __( 'No media items found. Try a different search.' ), 5192 /* translators: %s: Media item title or file name. */ 5193 'mediaItemViewed' => __( 'Viewing media item: %s' ), 5192 5194 5193 5195 // Library Details. -
trunk/tests/qunit/wp-admin/js/theme.js
r61629 r62878 13 13 previousTheme: function() { prevCalled++; }, 14 14 keyEvent: function( event ) { 15 if ( event.shiftKey || event.ctrlKey || event. altKey || event.metaKey ) {15 if ( event.shiftKey || event.ctrlKey || event.metaKey ) { 16 16 return; 17 17 } 18 18 19 19 // Right arrow 20 if ( event.keyCode === 39 ) { 20 if ( event.altKey && event.keyCode === 39 ) { 21 event.preventDefault(); 21 22 this.nextTheme(); 22 23 } 23 24 // Left arrow 24 else if ( event.keyCode === 37 ) { 25 else if ( event.altKey && event.keyCode === 37 ) { 26 event.preventDefault(); 25 27 this.previousTheme(); 26 28 } … … 35 37 }); 36 38 37 QUnit.test( 'Arrow keys with out modifiers', function( assert ) {39 QUnit.test( 'Arrow keys with Alt modifier', function( assert ) { 38 40 // Right arrow 39 41 themePreview.keyEvent( $.Event( 'keydown', { 40 42 keyCode: 39, 43 altKey: true, 41 44 shiftKey: false, 42 45 ctrlKey: false 43 46 }) ); 44 assert.equal( nextCalled, 1, ' Right arrow triggers nextTheme' );47 assert.equal( nextCalled, 1, 'Alt + Right arrow triggers nextTheme' ); 45 48 46 49 // Left arrow 47 50 themePreview.keyEvent( $.Event( 'keydown', { 48 51 keyCode: 37, 52 altKey: true, 49 53 shiftKey: false, 50 54 ctrlKey: false 51 55 }) ); 52 assert.equal( prevCalled, 1, ' Left arrow triggers previousTheme' );56 assert.equal( prevCalled, 1, 'Alt + Left arrow triggers previousTheme' ); 53 57 } ); 58 59 QUnit.test( 'Arrow keys without Alt do nothing', function( assert ) { 60 // Right arrow without Alt - should NOT call nextTheme 61 themePreview.keyEvent( $.Event( 'keydown', { 62 keyCode: 39, 63 altKey: false, 64 shiftKey: false, 65 ctrlKey: false 66 }) ); 67 assert.equal( nextCalled, 0, 'Right arrow without Alt does nothing' ); 68 69 // Left arrow without Alt - should NOT call previousTheme 70 themePreview.keyEvent( $.Event( 'keydown', { 71 keyCode: 37, 72 altKey: false, 73 shiftKey: false, 74 ctrlKey: false 75 }) ); 76 assert.equal( prevCalled, 0, 'Left arrow without Alt does nothing' ); 77 } ); 78 79 QUnit.test( 'PreventDefault is called for arrow keys with Alt', function( assert ) { 80 // This test would need to check if preventDefault was called 81 var event = $.Event( 'keydown', { 82 keyCode: 39, 83 altKey: true, 84 shiftKey: false, 85 ctrlKey: false 86 }); 87 88 // Mock the preventDefault method to track if it's called 89 var preventDefaultCalled = false; 90 event.preventDefault = function() { 91 preventDefaultCalled = true; 92 }; 93 94 themePreview.keyEvent( event ); 95 assert.ok( preventDefaultCalled, 'preventDefault is called for arrow keys with Alt' ); 96 }); 54 97 55 98 QUnit.test( 'Shift+Arrow keys do nothing', function( assert ) { … … 57 100 themePreview.keyEvent( $.Event( 'keydown', { 58 101 keyCode: 39, 102 altKey: false, 59 103 shiftKey: true, 60 104 ctrlKey: false … … 65 109 themePreview.keyEvent( $.Event( 'keydown', { 66 110 keyCode: 37, 111 altKey: false, 67 112 shiftKey: true, 68 113 ctrlKey: false … … 75 120 themePreview.keyEvent( $.Event( 'keydown', { 76 121 keyCode: 39, 122 altKey: false, 77 123 ctrlKey: true, 78 124 shiftKey: false … … 83 129 themePreview.keyEvent( $.Event( 'keydown', { 84 130 keyCode: 37, 131 altKey: false, 85 132 ctrlKey: true, 86 133 shiftKey: false
Note:
See TracChangeset
for help on using the changeset viewer.