Bug 251425 - Unexpected focus-within behaviour when layout is forced during blur event
Summary: Unexpected focus-within behaviour when layout is forced during blur event
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-01-31 01:31 PST by Bastien Caudan
Modified: 2023-02-07 01:32 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bastien Caudan 2023-01-31 01:31:23 PST
On a case where an element visibility is conditioned by a :focus-within pseudo class:

<style>
  .dropdown .dropdown-content {
    visibility: hidden;
  }
  .dropdown:focus-within .dropdown-content {
    visibility: visible;
  }
</style>
<div class="dropdown">
  <label tabindex="0">Click</label>
  <ul tabindex="0" class="dropdown-content">
    <li><a href="#foo">Go to foo</a></li>
    <li><a href="#bar">Go to bar</a></li>
  </ul>
</div>

When switching the focus to an inner element (clicking on one of the links) with a forced layout during the blur event, the inner element is not focused. 
Without the forced layout on the blur event it behaves as expected.

I have setup a reproduction case here: https://codesandbox.io/s/stupefied-andras-p79o0x?file=/index.html
Other browsers seem to handle this case without issue.
Comment 1 Radar WebKit Bug Importer 2023-02-07 01:32:17 PST
<rdar://problem/105118742>