Skip to content

Escape does not return focus to triggering element SVG  #282

@bnjmnrsh

Description

@bnjmnrsh

I've run into an issue with v3.0.0-dev, where with keyboard navigation, focus is not returned to the initial element (within an SVG) when using the escape key.

the offending lines

            // We return focus only if the current focus is inside this instance
            if (
                activeElement
                // &&
                // (
                //     document.activeElement === element[0] ||
                //     $.contains(element[0], document.activeElement)
                // )
            ) {
                try {
                    activeElement?.focus();  // optional chaining
                } catch (e) {
                  // Ignore exceptions, eg. for SVG elements which can't be
                  // focused in IE11
                  console.log(e);
                }
            }

Im my tests removing the checks and applying optional chaining on the activeElement?.focus(); results in the ideal behaviour, but obviously breaks IE11 compatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions