@@ -248,5 +248,80 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) =>
248248 await page . keyboard . press ( 'End' ) ;
249249 await expect ( vanillaTextarea ) . toBeFocused ( ) ;
250250 } ) ;
251+
252+ test ( 'should not override keyboard interactions for input elements' , async ( { page, browserName } ) => {
253+ const tabKey = browserName === 'webkit' ? 'Alt+Tab' : 'Tab' ;
254+ const popover = page . locator ( 'ion-popover' ) ;
255+ const innerNativeInput = page . locator ( 'ion-input input' ) . nth ( 0 ) ;
256+ const vanillaInput = page . locator ( 'ion-input + input' ) ;
257+
258+ await popoverFixture . open ( '#popover-with-input' ) ;
259+
260+ /**
261+ * Focusing happens async inside of popover so we need
262+ * to wait for the requestAnimationFrame to fire.
263+ */
264+ await expect ( popover ) . toBeFocused ( ) ;
265+
266+ // Tab should focus the native input inside ion-input
267+ await page . keyboard . press ( tabKey ) ;
268+
269+ // for Firefox, ion-input is focused first
270+ // need to tab again to get to native input
271+ if ( browserName === 'firefox' ) {
272+ await page . keyboard . press ( tabKey ) ;
273+ }
274+
275+ await expect ( innerNativeInput ) . toBeFocused ( ) ;
276+
277+ // Arrow keys should work on the ion-input
278+ await page . keyboard . press ( 'ArrowDown' ) ;
279+ await expect ( innerNativeInput ) . toBeFocused ( ) ;
280+
281+ await page . keyboard . press ( 'ArrowUp' ) ;
282+ await expect ( innerNativeInput ) . toBeFocused ( ) ;
283+
284+ // Tab again should focus the vanilla input
285+ await page . keyboard . press ( tabKey ) ;
286+ await expect ( vanillaInput ) . toBeFocused ( ) ;
287+
288+ // Arrow keys should work on the vanilla input
289+ await page . keyboard . press ( 'ArrowDown' ) ;
290+ await expect ( vanillaInput ) . toBeFocused ( ) ;
291+
292+ await page . keyboard . press ( 'ArrowUp' ) ;
293+ await expect ( vanillaInput ) . toBeFocused ( ) ;
294+
295+ await page . keyboard . press ( 'Home' ) ;
296+ await expect ( vanillaInput ) . toBeFocused ( ) ;
297+
298+ await page . keyboard . press ( 'End' ) ;
299+ await expect ( vanillaInput ) . toBeFocused ( ) ;
300+ } ) ;
301+
302+ test ( 'should move focus between buttons' , async ( { page, browserName } ) => {
303+ const tabKey = browserName === 'webkit' ? 'Alt+Tab' : 'Tab' ;
304+ const buttons = page . locator ( 'ion-popover button' ) ;
305+
306+ await popoverFixture . open ( '#popover-with-buttons' ) ;
307+
308+ await page . keyboard . press ( tabKey ) ;
309+ await expect ( buttons . nth ( 0 ) ) . toBeFocused ( ) ;
310+
311+ await page . keyboard . press ( tabKey ) ;
312+ await expect ( buttons . nth ( 1 ) ) . toBeFocused ( ) ;
313+
314+ await page . keyboard . press ( tabKey ) ;
315+ await expect ( buttons . nth ( 0 ) ) . toBeFocused ( ) ;
316+
317+ await page . keyboard . press ( `Shift+${ tabKey } ` ) ;
318+ await expect ( buttons . nth ( 1 ) ) . toBeFocused ( ) ;
319+
320+ await page . keyboard . press ( `Shift+${ tabKey } ` ) ;
321+ await expect ( buttons . nth ( 0 ) ) . toBeFocused ( ) ;
322+
323+ await page . keyboard . press ( `Shift+${ tabKey } ` ) ;
324+ await expect ( buttons . nth ( 1 ) ) . toBeFocused ( ) ;
325+ } ) ;
251326 } ) ;
252327} ) ;
0 commit comments