Skip to content

Fallback focus is not selected in the case of absence of initial focus element #1218

@konradr33

Description

@konradr33

Hi,
I'm currently struggling with the situation that after creating a focus trap, it wants to focus on a certain element at the start (I use initialFocus).
This element does not always exist. In this case, I wanted to use fallbackFocus.
However, testing this case and reviewing the code I come to the conclusion that this does not work as I thought.
In getInitialFocusNode the element to focus is retrieved by let node = getNodeForOption('initialFocus'). However, getNodeForOption in the absence of such an element throws an error .... refers to no known node. In my opinion, the fallbackFocus element should be focused in this scenario, but we don't get to that point in the code. Do I understand this behaviour correctly, or perhaps it works correctly?
I can create a PR if needed, or explain in more detail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions