To improve accessibility, I want to set the modal div with aria-hidden="false"
only one which is focusable recursively, and prevent any focus outside the modal div.
I can do that with targeting the focus of elements (and prevent clicks by CSS), in the way when the focus moved outside of the modal, immediately refocus it back to the last focused element inside the modal.
I'm not sure if this is the best way, so I would like to receive other ideas.
For note,
I do not like the way with setting tabindex="-1"
to many elements,
and I also tried to use element.blur()
which did nothing.