oddbird / popover-polyfill

Polyfills the HTML popover attribute and showPopover/hidePopover/togglePopover methods onto HTMLElement, as well as the popovertarget and popovertargetaction attributes on <button> elements.
BSD 3-Clause "New" or "Revised" License
249 stars 14 forks source link

`_a.focus is not a function` with `delegatesFocus: true`, but no focusable element #154

Closed jpzwarte closed 9 months ago

jpzwarte commented 9 months ago

So my fix for #149 works as it's supposed to. The scenario I did not account for is when there is no focusable content in the web component. In that case focusDelegate still returns the ShadowRoot and then errors in the popoverFocusingSteps.

I think this is due to the TreeWalker code where isFocusable falls through all the if statements and then returns focusTarget.tabIndex !== -1 which is true for the ShadowRoot?

jgerigmeyer commented 9 months ago

@jpzwarte Thanks! Released in v0.3.5 🚀