Skip to content

bug: Keyboard focus order breaks when using slot="fixed" in IonContent #30406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
ijsje71 opened this issue May 12, 2025 · 0 comments
Open
3 tasks done

bug: Keyboard focus order breaks when using slot="fixed" in IonContent #30406

ijsje71 opened this issue May 12, 2025 · 0 comments
Labels

Comments

@ijsje71
Copy link

ijsje71 commented May 12, 2025

Prerequisites

Ionic Framework Version

v8.x

Current Behavior

The keyboard focus for accessibility works quite well with Ionic and can be modified to include elements that would normally not be included in the keyboard focus. Using ion-focusable and the ion-focused classes I can create a pleasant experience for users that rely on keyboard focus instead of a mouse.

The only problem I'm facing with keyboard focus is elements that receive the slot="fixed" property in an element that's a child of IonContent. When an element is placed at the very top of the DOM with the slot="fixed" property, it is receives focus as the very last element, even though it is placed on top of the DOM.

I've tried using tab indexes to influence the order of the keyboard focus, without any success. My guess is that this is related to the fact that the slot="fixed" property places the content behind the other items in IonContent in the shadow DOM.

Expected Behavior

I expect the keyboard focus to ignore the fact what slot it receives in the shadow DOM and the slot="fixed" does not interfere with the order that the DOM is read.

Steps to Reproduce

  1. Go to https://stackblitz.com/~/github.com/ijsje71/keyboard-focus-order-wrong-position-fixed and open the example in full screen mode (or clone the repository and run the project locally)

  2. Start the app

  3. Press tab to trigger the keyboard focus

  4. Keep pressing tab until you've focused all the items

  5. Notice that the segmented picker at the top of the page is focused last

  6. Now remove the slot="fixed" tag on the segmented picker

  7. Press tab to trigger the keyboard focus again and keep pressing it to see the order

  8. Notice that the keyboard focus is behaving as expected

This is unexpected behaviour, as the segmented picker is positioned at the top of the DOM. If the segmented picker opens different content, the user needs to keep tabbing through the entire page until it reaches the content again. This is not much of an issue, but this becomes a bigger problem when there's more content on the surrounding pages such as a menu. Skiplinks can be used as a workaround for this issue, but this is not ideal.

Code Reproduction URL

https://github.com/ijsje71/keyboard-focus-order-wrong-position-fixed#

Ionic Info

Ionic:

Ionic CLI : 7.2.0
Ionic Framework : @ionic/react 8.5.7

Capacitor:

Capacitor CLI : 7.2.0
@capacitor/android : not installed
@capacitor/core : 7.2.0
@capacitor/ios : not installed

Utility:

cordova-res : not installed globally
native-run : 2.0.1

System:

NodeJS : v22.14.0
npm : 10.9.2
OS : macOS Unknown

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant