#When we open a modal from the menu item element, focus doesn't return to the target element on ESC.

1 messages · Page 1 of 1 (latest)

sacred berry
#

Is there a way to return focus to the menu target element once we close the modal with ESC? In this scenario last active element would be the menu item which we clicked but it's difficult to focus that element as the menu is already closed by then. We can just focus the menu target element.

I checked use-focus-return and use-focus-trap but could not seem to figure it out.

I would greatly appreciate your help regarding this matter.

sacred berry
#

When we open a modal from the menu item element, focus doesn't return to the target element on ESC.

strong sapphire
sacred berry
#

What i mean to say is that the menu item when clicked opens a Mantine's Modal component. If we close Modal (not Menu) with ESC the focus doesn't return to Menu Element's Target Button. Does this make sense? Please let me know if you need any more info. Appreciate your help.
@strong sapphire

strong sapphire
sacred berry
#

Yes, that makes sense. So I was wondering if there is a way we can trap the focus in <Menu.Target> element. It messes the program flow as we need to start tabbing from the very top of the page. Does it make sense?

#

It will be section 508 compliant (accessibility)

strong sapphire
#

However, this seems like a workaround, maybe there is a better option

sacred berry
#

thank you for your help. Sure, maybe @crisp notch has some ideas too. 🙂