Facus trap component

Hello,

How can I make focus trap for some fields in Vaadin?

Hey Atila,

I’d be interested in hearing your use case. From an accessibility point-of-view, focus traps are a no-go.

Hello,

I will try to explain. Suppose we have a form with some fields. These fields has navigation route with tab index. But when user press tab an go throug all fields focus lost and put in browser other parts (url or something else). I want to limit navigation just for fields in form not out this form.

I hope succeed to explain my situation.

Attila

But when user press tab an go throug all fields focus lost and put in browser other parts (url or something else).

Users that use tab to move focus should know that shift+tab will move the focus back instead of forward. Please be aware that there are users that rely solely on keyboard navigation, and these users MUST have a way to move the focus out of your form. Please have a look at the [keyboard trap section]
(https://www.w3.org/TR/UNDERSTANDING-WCAG20/keyboard-operation-trapping.html) of the [Web Content Accessibility Guidelines (WCAG) 2.0]
(https://www.w3.org/TR/WCAG20/).

If your form is within a Dialog, you could for example have a close button that is focusable within your focus trap loop. Then your desired focus trap loop over all form-fields and -actions would be okay to do.