It seems trivial but I can’t find a solution that works without issues.
Consider a parent div, I want to get the first focusable element in this div.
Many edge cases to consider:
- the child might be in a parent hierarchy that is disabled
- the child might be in a parent hierarchy that is not visible / displayed
- the child or some parent might have tabindex -1
- the child might be in a parent hierarchy that is inert
And probably more?
Can someone find a solution that works and handles all edge cases?
It would be preferable if it didn’t have to iterate everything.