@@ -29,10 +29,10 @@ export interface Props {
2929}
3030
3131class ComponentViewer extends Component < Props , ComponentViewerState > {
32- private registries : Registries ;
33- private stateCreator : ComponentViewerStateCreator ;
32+ private readonly registries : Registries ;
33+ private readonly hotKeyBoundActions : HotKeyBoundActions ;
3434
35- private hotKeyBoundActions : HotKeyBoundActions ;
35+ private stateCreator : ComponentViewerStateCreator ;
3636
3737 constructor ( props : Props ) {
3838 super ( props ) ;
@@ -43,7 +43,9 @@ class ComponentViewer extends Component<Props, ComponentViewerState> {
4343 this . stateCreator = new ComponentViewerStateCreator ( this . registries ) ;
4444
4545 this . state = this . stateFromUrl ( ) ;
46- this . hotKeyBoundActions = { 'Alt F' : this . onFullScreenToggle } ;
46+ this . hotKeyBoundActions = {
47+ 'Alt F' : this . onFullScreenToggle ,
48+ ...this . dropDownKeyBoundActions ( ) } ;
4749 }
4850
4951 render ( ) {
@@ -169,6 +171,21 @@ class ComponentViewer extends Component<Props, ComponentViewerState> {
169171 this . unsubscribeFromUrlChanges ( ) ;
170172 }
171173
174+ private dropDownKeyBoundActions ( ) {
175+ const result : HotKeyBoundActions = { } ;
176+
177+ const { dropDown} = this . props ;
178+ if ( ! dropDown ) {
179+ return result ;
180+ }
181+
182+ dropDown . items
183+ . filter ( item => ! ! item . hotKey )
184+ . forEach ( item => result [ item . hotKey ! ] = ( ) => this . selectToolbarItem ( item . label ) ) ;
185+
186+ return result ;
187+ }
188+
172189 private subscribeToUrlChanges ( ) {
173190 window . addEventListener ( 'popstate' , ( ) => this . updateStateFromUrl ( ) ) ;
174191 }
0 commit comments