@@ -259,4 +259,56 @@ describe("Toolbar", () => {
259259
260260 await disconnect ( ) ;
261261 } ) ;
262+
263+ it ( "should handle focusin when focusableElements becomes undefined" , async ( ) => {
264+ const { element, connect, disconnect, document, startButton } = await setup ( ) ;
265+
266+ await connect ( ) ;
267+
268+ const tempButton = document . createElement ( 'button' ) ;
269+ document . body . appendChild ( tempButton ) ;
270+ tempButton . focus ( ) ;
271+ await DOM . nextUpdate ( ) ;
272+
273+ expect ( document . activeElement ) . to . equal ( tempButton ) ;
274+
275+ Reflect . set ( element as object , "focusableElements" , undefined ) ;
276+ await DOM . nextUpdate ( ) ;
277+
278+ startButton . focus ( ) ;
279+ await DOM . nextUpdate ( ) ;
280+
281+ expect ( document . activeElement ) . to . equal ( startButton ) ;
282+
283+ tempButton . remove ( ) ;
284+ await disconnect ( ) ;
285+ } ) ;
286+
287+ it ( "should handle keydown when focusableElements becomes undefined" , async ( ) => {
288+ const { element, connect, disconnect, document, startButton } = await setup ( ) ;
289+
290+ await connect ( ) ;
291+
292+ const tempButton = document . createElement ( "button" ) ;
293+ document . body . appendChild ( tempButton ) ;
294+ tempButton . focus ( ) ;
295+ await DOM . nextUpdate ( ) ;
296+
297+ expect ( document . activeElement ) . to . equal ( tempButton ) ;
298+
299+ startButton . focus ( ) ;
300+ await DOM . nextUpdate ( ) ;
301+
302+ Reflect . set ( element as object , "reduceFocusableElements" , ( ) => undefined ) ;
303+ Reflect . set ( element as object , "focusableElements" , undefined ) ;
304+ await DOM . nextUpdate ( ) ;
305+
306+ pressRightArrowKey ( element ) ;
307+ await DOM . nextUpdate ( ) ;
308+
309+ expect ( document . activeElement ) . to . equal ( startButton ) ;
310+
311+ tempButton . remove ( ) ;
312+ await disconnect ( ) ;
313+ } ) ;
262314} ) ;
0 commit comments