PolymerElements / iron-overlay-behavior

Makes an element an overlay with an optional backdrop
41 stars 71 forks source link

Restore focus if the node with focus in the overlay is distributed into it. #305

Closed bicknellr closed 4 years ago

bicknellr commented 4 years ago

Before this PR, focus was only restored when closing an overlay if there was no focused element (or <body>) or the focused element was a shadow-including descendant of the overlay. This prevented focus from being restored if the focused element inside the overlay was distributed into the overlay through a slot:

<outer-element>
  #shadow-root
    <element-with-iron-overlay-behavior>
      <slot name="in-overlay">
    </element-with-iron-overlay-behavior>
  #/shadow-root
  <input slot="in-overlay">
</outer-element>

This PR changes the test to check that the focused node is any descendant of the overlay in the flattened tree.