@@ -4,13 +4,15 @@ import { later } from "@ember/runloop";
44import layout from './template' ;
55import { EKMixin , keyUp } from 'ember-keyboard' ;
66import { inject as service } from '@ember/service' ;
7+ import { formElementHasFocus } from '../../keyboard-config' ;
78
89/**
910 A component that enables keyboard shortcuts. Press '?' to toggle the keyboard shortcuts dialog.
1011
1112 @class DocsKeyboardShortcuts
1213 @public
1314*/
15+
1416export default Component . extend ( EKMixin , {
1517 layout,
1618
@@ -23,26 +25,34 @@ export default Component.extend(EKMixin, {
2325 } ) ,
2426
2527 goto : on ( keyUp ( 'KeyG' ) , function ( ) {
26- this . set ( 'isGoingTo' , true ) ;
27- later ( ( ) => {
28- this . set ( 'isGoingTo' , false ) ;
29- } , 500 ) ;
28+ if ( ! formElementHasFocus ( ) ) {
29+ this . set ( 'isGoingTo' , true ) ;
30+ later ( ( ) => {
31+ this . set ( 'isGoingTo' , false ) ;
32+ } , 500 ) ;
33+ }
3034 } ) ,
3135
3236 gotoDocs : on ( keyUp ( 'KeyD' ) , function ( ) {
33- if ( this . get ( 'isGoingTo' ) ) {
34- this . get ( 'router' ) . transitionTo ( 'docs' ) ;
37+ if ( ! formElementHasFocus ( ) ) {
38+ if ( this . get ( 'isGoingTo' ) ) {
39+ this . get ( 'router' ) . transitionTo ( 'docs' ) ;
40+ }
3541 }
3642 } ) ,
3743
3844 gotoHome : on ( keyUp ( 'KeyH' ) , function ( ) {
39- if ( this . get ( 'isGoingTo' ) ) {
40- this . get ( 'router' ) . transitionTo ( 'index' ) ;
45+ if ( ! formElementHasFocus ( ) ) {
46+ if ( this . get ( 'isGoingTo' ) ) {
47+ this . get ( 'router' ) . transitionTo ( 'index' ) ;
48+ }
4149 }
4250 } ) ,
4351
4452 toggleKeyboardShortcuts : on ( keyUp ( 'shift+Slash' ) , function ( ) {
45- this . toggleProperty ( 'isShowingKeyboardShortcuts' ) ;
53+ if ( ! formElementHasFocus ( ) ) {
54+ this . toggleProperty ( 'isShowingKeyboardShortcuts' ) ;
55+ }
4656 } ) ,
4757
4858 actions : {
0 commit comments