File tree Expand file tree Collapse file tree 4 files changed +59
-2
lines changed
design/adminhtml/Magento/backend/web/js Expand file tree Collapse file tree 4 files changed +59
-2
lines changed Original file line number Diff line number Diff line change 1111 <section name =" AdminHeaderSection" >
1212 <element name =" pageTitle" type =" text" selector =" .page-header h1.page-title" />
1313 <element name =" adminUserAccountText" type =" text" selector =" .page-header .admin-user-account-text" />
14+ <element name =" globalSearchInput" type =" text" selector =" #search-global" />
15+ <element name =" globalSearchInputVisible" type =" text" selector =" .search-global-field._active #search-global" />
1416 <!-- Legacy heading section. Mostly used for admin 404 and 403 pages -->
1517 <element name =" pageHeading" type =" text" selector =" .page-content .page-heading" />
1618 <!-- Used for page not found error -->
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <!--
3+ /**
4+ * Copyright © Magento, Inc. All rights reserved.
5+ * See COPYING.txt for license details.
6+ */
7+ -->
8+
9+ <tests xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
10+ xsi : noNamespaceSchemaLocation =" urn:magento:mftf:Test/etc/testSchema.xsd" >
11+ <test name =" AdminSearchHotkeyTest" >
12+ <annotations >
13+ <features value =" Backend" />
14+ <stories value =" Search form hotkey in backend" />
15+ <title value =" Admin should be able focus on the search field with a hotkey" />
16+ <description value =" Admin should be able focus on the search field with a hotkey - forwardslash" />
17+ <severity value =" MINOR" />
18+ <group value =" backend" />
19+ <group value =" search" />
20+ </annotations >
21+ <before >
22+ <actionGroup ref =" AdminLoginActionGroup" stepKey =" LoginAsAdmin" />
23+ </before >
24+ <after >
25+ <actionGroup ref =" AdminLogoutActionGroup" stepKey =" logout" />
26+ </after >
27+
28+ <pressKey selector =" body" parameterArray =" [/]" stepKey =" pressForwardslashKey" />
29+ <seeElement selector =" {{AdminHeaderSection.globalSearchInputVisible}}" stepKey =" seeActiveGlobalSearchInput" />
30+ <seeInField userInput =" " selector =" {{AdminHeaderSection.globalSearchInput}}" stepKey =" seeEmptyGlobalSearchInput" />
31+ <pressKey selector =" {{AdminHeaderSection.globalSearchInput}}" parameterArray =" [/]" stepKey =" pressForwardslashKeyAgain" />
32+ <seeInField userInput =" /" selector =" {{AdminHeaderSection.globalSearchInput}}" stepKey =" seeForwardSlashInGlobalSearchInput" />
33+ </test >
34+ </tests >
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ define([], function () {
2121 17 : 'ctrlKey' ,
2222 18 : 'altKey' ,
2323 16 : 'shiftKey' ,
24+ 191 : 'forwardSlashKey' ,
2425 66 : 'bKey' ,
2526 73 : 'iKey' ,
2627 85 : 'uKey'
Original file line number Diff line number Diff line change @@ -312,8 +312,9 @@ define('globalNavigation', [
312312
313313define ( 'globalSearch' , [
314314 'jquery' ,
315- 'jquery/ui'
316- ] , function ( $ ) {
315+ 'Magento_Ui/js/lib/key-codes' ,
316+ 'jquery-ui-modules/widget'
317+ ] , function ( $ , keyCodes ) {
317318 'use strict' ;
318319
319320 $ . widget ( 'mage.globalSearch' , {
@@ -345,6 +346,25 @@ define('globalSearch', [
345346 this . input . on ( 'focus.activateGlobalSearchForm' , function ( ) {
346347 self . field . addClass ( self . options . fieldActiveClass ) ;
347348 } ) ;
349+
350+ $ ( document ) . on ( 'keydown.activateGlobalSearchForm' , function ( event ) {
351+ var inputs = [
352+ 'input' ,
353+ 'select' ,
354+ 'textarea'
355+ ] ;
356+
357+ if ( keyCodes [ event . which ] !== 'forwardSlashKey' ||
358+ inputs . indexOf ( event . target . tagName . toLowerCase ( ) ) !== - 1 ||
359+ event . target . isContentEditable
360+ ) {
361+ return ;
362+ }
363+
364+ event . preventDefault ( ) ;
365+
366+ self . input . focus ( ) ;
367+ } ) ;
348368 }
349369 } ) ;
350370
You can’t perform that action at this time.
0 commit comments