<?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>220580</bug_id>
          
          <creation_ts>2021-01-12 23:04:38 -0800</creation_ts>
          <short_desc>REGRESSION (r257839): Element cannot be &quot;focus()&quot;ed right after becoming visible from hidden</short_desc>
          <delta_ts>2021-01-14 01:38:51 -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>DOM</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>217240</dup_id>
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=208504</see_also>
          <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="Tomoki Imai">tomoki.imai</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>koivisto</cc>
    
    <cc>tomoki.imai</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1719215</commentid>
    <comment_count>0</comment_count>
      <attachid>417510</attachid>
    <who name="Tomoki Imai">tomoki.imai</who>
    <bug_when>2021-01-12 23:04:38 -0800</bug_when>
    <thetext>Created attachment 417510
Testcase

We found a regression from r257839.

Here is how to reproduce:
1. Open the attached html with MiniBrowser
2. Push Enter key

Expected result:
Newly appeared &quot;Menu Item&quot; button should have focus.

Actual result:
Newly appeared &quot;Menu Item&quot; button doesn&apos;t have focus.

Reproduced environment:
- WinCairo MiniBrowser (r271389)

Note:
- I confirmed that reverting r257839 solves the issue.
- Chrome (87.0.4280.141) and Firefox (84.0.1) on Windows don&apos;t have this issue
- I didn&apos;t test Safari, but because the changed code in r257839 is platform-independent code, I hope it can be reproduced in Safari too.

Attached test case description:
&quot;Menu Item&quot; button is at first invisible, because the div which contains the button is &quot;display:none&quot;.
When Enter key is hit, &quot;open&quot; class is added, and it should overwrite &quot;display&quot; with &quot;block&quot;.
Then we call &quot;focus&quot; on the button. Because button is visible now, it should have focus.

// open menu
document.querySelector(&apos;.menu&apos;).classList.add(&apos;open&apos;);
// focus on menu item
document.querySelector(&apos;.menu-item&apos;).focus();

&lt;div class=&quot;menu&quot;&gt;
    &lt;ul&gt;
        &lt;li&gt;
            &lt;button class=&quot;menu-item&quot;&gt;Menu Item&lt;/button&gt;
        &lt;/li&gt;
    &lt;/ul&gt;
&lt;/div&gt;

.menu {
    display: none;
    background: #000;
}
.open {
    display: block;
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1719265</commentid>
    <comment_count>1</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2021-01-13 05:30:44 -0800</bug_when>
    <thetext>I can&apos;t repro on Safari (the menu opens fine) but I believe this is the same bug as 217240.

*** This bug has been marked as a duplicate of bug 217240 ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1719269</commentid>
    <comment_count>2</comment_count>
    <who name="Tomoki Imai">tomoki.imai</who>
    <bug_when>2021-01-13 06:02:40 -0800</bug_when>
    <thetext>Antti,

Thanks for the info, sorry, I&apos;m not sure why I missed that ticket.

This bug and bug bug 217240 seems to be same.
I confirmed that attachment 417524 in bug 217240 fixes this issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1719559</commentid>
    <comment_count>3</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2021-01-14 01:38:51 -0800</bug_when>
    <thetext>Thanks for confirmation!</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>417510</attachid>
            <date>2021-01-12 23:04:38 -0800</date>
            <delta_ts>2021-01-12 23:04:38 -0800</delta_ts>
            <desc>Testcase</desc>
            <filename>test.html</filename>
            <type>text/html</type>
            <size>1276</size>
            <attacher name="Tomoki Imai">tomoki.imai</attacher>
            
              <data encoding="base64">PCFkb2N0eXBlIGh0bWw+DQo8aHRtbCBsYW5nPSJlbiI+DQoNCjxoZWFkPg0KICAgIDxtZXRhIGNo
YXJzZXQ9InV0Zi04Ij4NCiAgICA8dGl0bGU+VGVzdDwvdGl0bGU+DQo8L2hlYWQ+DQoNCjxzdHls
ZT4NCiAgICBib2R5IHsNCiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogcmdiKDMzLCAzMywgMzMp
Ow0KICAgIH0NCiAgICAubWVudSB7DQogICAgICAgIGRpc3BsYXk6IG5vbmU7DQogICAgICAgIGJh
Y2tncm91bmQ6ICMwMDA7DQogICAgfQ0KICAgIC5tZW51IHVsIHsNCiAgICAgICAgbGlzdC1zdHls
ZTogbm9uZTsNCiAgICB9DQogICAgLm9wZW4gew0KICAgICAgICBkaXNwbGF5OiBibG9jazsNCiAg
ICB9DQo8L3N0eWxlPg0KPHNjcmlwdD4NCiAgICB3aW5kb3cuYWRkRXZlbnRMaXN0ZW5lcignbG9h
ZCcsICgpID0+IHsNCiAgICAgICAgZG9jdW1lbnQucXVlcnlTZWxlY3RvcignLm9wZW4tYnV0dG9u
JykuZm9jdXMoKTsNCiAgICB9KTsNCg0KICAgIHdpbmRvdy5hZGRFdmVudExpc3RlbmVyKCdrZXlk
b3duJywgKGV2dCkgPT4gew0KICAgICAgICBpZiAoZXZ0LmtleUNvZGUgPT09IDEzKSB7IC8vIEVu
dGVyDQogICAgICAgICAgICAvLyBvcGVuIG1lbnUNCiAgICAgICAgICAgIGRvY3VtZW50LnF1ZXJ5
U2VsZWN0b3IoJy5tZW51JykuY2xhc3NMaXN0LmFkZCgnb3BlbicpOw0KICAgICAgICAgICAgLy8g
Zm9jdXMgb24gbWVudSBpdGVtDQogICAgICAgICAgICBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCcu
bWVudS1pdGVtJykuZm9jdXMoKTsNCiAgICAgICAgfSBlbHNlIGlmIChldnQua2V5Q29kZSA9PT0g
MjcpIHsgLy8gRVNDDQogICAgICAgICAgICAvLyBjbG9zZSBtZW51DQogICAgICAgICAgICBkb2N1
bWVudC5xdWVyeVNlbGVjdG9yKCcubWVudScpLmNsYXNzTGlzdC5yZW1vdmUoJ29wZW4nKTsNCiAg
ICAgICAgICAgIC8vIGZvY3VzIG9uIGJ1dHRvbg0KICAgICAgICAgICAgZG9jdW1lbnQucXVlcnlT
ZWxlY3RvcignLm9wZW4tYnV0dG9uJykuZm9jdXMoKTsNCiAgICAgICAgfQ0KICAgIH0pOw0KPC9z
Y3JpcHQ+DQoNCjxib2R5Pg0KICAgIDxidXR0b24gY2xhc3M9Im9wZW4tYnV0dG9uIj5PcGVuIE1l
bnU8L2J1dHRvbj4NCiAgICA8ZGl2IGNsYXNzPSJtZW51Ij4NCiAgICAgICAgPHVsPg0KICAgICAg
ICAgICAgPGxpPg0KICAgICAgICAgICAgICAgIDxidXR0b24gY2xhc3M9Im1lbnUtaXRlbSI+TWVu
dSBJdGVtPC9idXR0b24+DQogICAgICAgICAgICA8L2xpPg0KICAgICAgICA8L3VsPg0KICAgIDwv
ZGl2Pg0KPC9ib2R5Pg0KPC9odG1sPg==
</data>

          </attachment>
      

    </bug>

</bugzilla>