lity icon indicating copy to clipboard operation
lity copied to clipboard

Escape does not return focus to triggering element SVG

Open bnjmnrsh opened this issue 3 years ago • 0 comments

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.

bnjmnrsh avatar Jun 02 '22 15:06 bnjmnrsh