File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
packages/core/useMagicKeys Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -154,4 +154,14 @@ describe('useMagicKeys', () => {
154154 window . dispatchEvent ( new Event ( 'focus' ) )
155155 expect ( alt_tab . value ) . toBe ( false )
156156 } )
157+
158+ it ( 'should handle empty key events without errors' , async ( ) => {
159+ const { a } = useMagicKeys ( { target } )
160+
161+ expect ( ( ) => {
162+ target . dispatchEvent ( new KeyboardEvent ( 'keyup' , { } ) )
163+ } ) . not . toThrow ( )
164+
165+ expect ( a . value ) . toBe ( false )
166+ } )
157167} )
Original file line number Diff line number Diff line change @@ -140,6 +140,9 @@ export function useMagicKeys<T extends boolean = false>(options: UseMagicKeysOpt
140140 const code = e . code ?. toLowerCase ( )
141141 const values = [ code , key ] . filter ( Boolean )
142142
143+ if ( key === '' )
144+ return
145+
143146 // current set
144147 if ( key ) {
145148 if ( value )
You can’t perform that action at this time.
0 commit comments