<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>309245</bug_id>
          
          <creation_ts>2026-03-05 02:17:06 -0800</creation_ts>
          <short_desc>:focus-visible is applied to button when opening native &lt;dialog&gt; via showModal() after pointer interaction</short_desc>
          <delta_ts>2026-03-05 11:02:41 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Forms</component>
          <version>Safari 18</version>
          <rep_platform>Mac (Apple Silicon)</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>247416</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Mateusz Daniluk">danilukmateusz92</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>a_protyasha</cc>
    
    <cc>cdumez</cc>
    
    <cc>koivisto</cc>
    
    <cc>ntim</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2187315</commentid>
    <comment_count>0</comment_count>
    <who name="Mateusz Daniluk">danilukmateusz92</who>
    <bug_when>2026-03-05 02:17:06 -0800</bug_when>
    <thetext>When a native &lt;dialog&gt; is opened via showModal() after a pointer click, Safari focuses the first button inside the dialog and applies :focus-visible.

This results in a visible focus ring even though the dialog was opened with a mouse/pointer interaction, which seems inconsistent with the intended heuristics of :focus-visible.

According to the expected behavior, :focus-visible should typically appear only when focus is triggered by keyboard navigation or other assistive mechanisms.

Steps to reproduce:
1. Open the reproduction example
2. Click the “Open dialog” button
3. The dialog opens via showModal()

Safari focuses the first button inside the dialog and applies :focus-visible

Reproduction
CodePen:
https://codepen.io/ptu14/pen/NPRNRQa

Expected result
The button may receive focus, but :focus-visible should not be applied when the dialog is opened via pointer interaction.

Actual result
The focused button receives :focus-visible, causing a visible focus ring immediately after opening the dialog.

Browser comparison
Chrome and Firefox also focuses the first button inside the dialog upon showModal(), however it correctly does not apply :focus-visible in this case. Chrome inherits the &quot;no focus ring&quot; state from the pointer interaction that triggered showModal(), so the programmatic focus inside the dialog does not show a focus ring.
Safari&apos;s behavior diverges. It applies :focus-visible regardless of how the dialog was opened, treating the programmatic focus from showModal() as if it were keyboard-initiated. This appears to be a specific issue with how WebKit propagates the pointer/keyboard interaction state across the showModal() focus boundary. The previously related bug #236782 (script focus after clicking a different button) is already fixed and this is a distinct case specific to &lt;dialog&gt;.showModal().


Environment

Safari Version 18.6 (20621.3.11.11.3) (macOS 15.7.3 (24G419))</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2187345</commentid>
    <comment_count>1</comment_count>
    <who name="Mateusz Daniluk">danilukmateusz92</who>
    <bug_when>2026-03-05 05:02:13 -0800</bug_when>
    <thetext>duplicate of https://bugs.webkit.org/show_bug.cgi?id=247416</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2187346</commentid>
    <comment_count>2</comment_count>
    <who name="Mateusz Daniluk">danilukmateusz92</who>
    <bug_when>2026-03-05 05:02:26 -0800</bug_when>
    <thetext>duplicate of https://bugs.webkit.org/show_bug.cgi?id=247416</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2187445</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2026-03-05 11:02:41 -0800</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 247416 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>