File tree 4 files changed +59
-2
lines changed
design/adminhtml/Magento/backend/web/js
4 files changed +59
-2
lines changed Original file line number Diff line number Diff line change 11
11
<section name =" AdminHeaderSection" >
12
12
<element name =" pageTitle" type =" text" selector =" .page-header h1.page-title" />
13
13
<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" />
14
16
<!-- Legacy heading section. Mostly used for admin 404 and 403 pages -->
15
17
<element name =" pageHeading" type =" text" selector =" .page-content .page-heading" />
16
18
<!-- 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 () {
21
21
17 : 'ctrlKey' ,
22
22
18 : 'altKey' ,
23
23
16 : 'shiftKey' ,
24
+ 191 : 'forwardSlashKey' ,
24
25
66 : 'bKey' ,
25
26
73 : 'iKey' ,
26
27
85 : 'uKey'
Original file line number Diff line number Diff line change @@ -312,8 +312,9 @@ define('globalNavigation', [
312
312
313
313
define ( 'globalSearch' , [
314
314
'jquery' ,
315
- 'jquery/ui'
316
- ] , function ( $ ) {
315
+ 'Magento_Ui/js/lib/key-codes' ,
316
+ 'jquery-ui-modules/widget'
317
+ ] , function ( $ , keyCodes ) {
317
318
'use strict' ;
318
319
319
320
$ . widget ( 'mage.globalSearch' , {
@@ -345,6 +346,25 @@ define('globalSearch', [
345
346
this . input . on ( 'focus.activateGlobalSearchForm' , function ( ) {
346
347
self . field . addClass ( self . options . fieldActiveClass ) ;
347
348
} ) ;
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
+ } ) ;
348
368
}
349
369
} ) ;
350
370
You can’t perform that action at this time.
0 commit comments