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:
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:This PR changes the test to check that the focused node is any descendant of the overlay in the flattened tree.