<?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>47182</bug_id>
          
          <creation_ts>2010-10-05 08:34:56 -0700</creation_ts>
          <short_desc>Focus remains on hidden element</short_desc>
          <delta_ts>2017-04-24 17:24:01 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.chromium.org/p/chromium/issues/detail?id=491828</see_also>
    
    <see_also>https://bugzilla.mozilla.org/show_bug.cgi?id=559561</see_also>
          <bug_file_loc>http://xirc.chez.com/ie9-focus-display-none.html</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="doum-ti-di-li-doom">duke_the_killer</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>cdumez</cc>
    
    <cc>code.vineet</cc>
    
    <cc>darin</cc>
    
    <cc>kaustubh.ra</cc>
    
    <cc>manian</cc>
    
    <cc>m.goleb+bugzilla</cc>
    
    <cc>rego</cc>
    
    <cc>rniwa</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>289628</commentid>
    <comment_count>0</comment_count>
      <attachid>69791</attachid>
    <who name="doum-ti-di-li-doom">duke_the_killer</who>
    <bug_when>2010-10-05 08:34:56 -0700</bug_when>
    <thetext>Created attachment 69791
Demo

Focus remains on element after its parent container is styled with display:none.

Wait a second until element is hidden.
Press any key.

You will receive a message, proving now-hidden element still has focus.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>289816</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2010-10-05 12:53:51 -0700</bug_when>
    <thetext>This is a difference with Firefox, but I don&apos;t see why this is necessarily a bad behavior.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>290047</commentid>
    <comment_count>2</comment_count>
    <who name="doum-ti-di-li-doom">duke_the_killer</who>
    <bug_when>2010-10-05 19:48:21 -0700</bug_when>
    <thetext>Inconsistency is bad

An element keeps its focus after being hidden
But a hidden element cannot gain focus

In fact, Internet Explorer is like Firefox when you set style.display=&quot;none&quot; (I was reporting the bug with that demo)

To recap:
http://xirc.chez.com/ie9-focus-1.html (focus then style.display)
Allowed by Opera / Safari

http://xirc.chez.com/ie9-focus-2.html (focus then className)
Allowed by Opera / Safari / Internet Explorer

http://xirc.chez.com/ie9-focus-3.html (style.display then focus)
Allowed by Opera

http://xirc.chez.com/ie9-focus-4.html (className then focus)
Allowed by Opera</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>290073</commentid>
    <comment_count>3</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2010-10-05 20:47:07 -0700</bug_when>
    <thetext>Yes, we should be different if IE and Firefox both do the same thing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>463935</commentid>
    <comment_count>4</comment_count>
    <who name="Kaustubh Atrawalkar">kaustubh.ra</who>
    <bug_when>2011-09-08 00:14:12 -0700</bug_when>
    <thetext>here the issue seems to be cancelFocusAppearenceUpdate() call. Which does remove the focus appearance but does not set the focus back to 0. The current usage of this call is only in focus() &amp; detach() calls in Element.cpp. We can add setFocus(0) in this function definition to avoid retaining of the focus after display:none. Element::blur() does the same thing, which we might able to use here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>479881</commentid>
    <comment_count>5</comment_count>
    <who name="Kaustubh Atrawalkar">kaustubh.ra</who>
    <bug_when>2011-10-07 02:11:29 -0700</bug_when>
    <thetext>Is this issue to be fixed? Seems to be inconsistent on different platforms.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>479929</commentid>
    <comment_count>6</comment_count>
    <who name="Vineet Chaudhary (vineetc)">code.vineet</who>
    <bug_when>2011-10-07 04:16:52 -0700</bug_when>
    <thetext>I think we have similar issue https://bugs.webkit.org/show_bug.cgi?id=40338 .</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>480518</commentid>
    <comment_count>7</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-10-08 00:46:56 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; Is this issue to be fixed? Seems to be inconsistent on different platforms.

I think we should fix it. But it&apos;ll be nice to bring it up on whatwg to specify this behavior if it hasn&apos;t been done so already.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>480522</commentid>
    <comment_count>8</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-10-08 00:53:25 -0700</bug_when>
    <thetext>One tricky part of fixing this bug will be that we must fire blur event before removing the focus. Since we wouldn&apos;t know whether an element is visible or not until style recalc, it might have a weird side effects.

For example, we had decided to remove the focus when at the end of style-recalc, we might have a trouble dealing with situations like:

var element = ...

element.focus();
element.style.display = &apos;none&apos;;
element.title = &apos;hello&apos;; // blur hasn&apos;t fired yet here
var x = element.offsetTop; // blur fires here

Because style recalc doesn&apos;t happen until offsetTop is obtained in the last line.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>480536</commentid>
    <comment_count>9</comment_count>
    <who name="Kaustubh Atrawalkar">kaustubh.ra</who>
    <bug_when>2011-10-08 02:18:42 -0700</bug_when>
    <thetext>Right, so if we fire the blur event and then call blur instead of cancelFocusApperance() will be right way to do it? Also, i tried with blur replacing cancelFocusApperance, but its causing few layout tests to be failed. Need to look in more detail.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>480571</commentid>
    <comment_count>10</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2011-10-08 09:59:04 -0700</bug_when>
    <thetext>We should be very careful when considering changes in this area. Accepting key events on an invisible element is a fairly common technique - my understanding is that even Google Docs does something similar.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>480576</commentid>
    <comment_count>11</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-10-08 10:43:21 -0700</bug_when>
    <thetext>(In reply to comment #9)
&gt; Right, so if we fire the blur event and then call blur instead of cancelFocusApperance() will be right way to do it? Also, i tried with blur replacing cancelFocusApperance, but its causing few layout tests to be failed. Need to look in more detail.

The real question is when to call those functions. Checking the computed value of display property of the focused node every time style changes is prohibitively inefficient and expensive. On the other hand, if we wait until style recalc happens, then there will be a noticeable delay between the time the element was hidden and blur is fired.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>573604</commentid>
    <comment_count>12</comment_count>
    <who name="Kaustubh Atrawalkar">kaustubh.ra</who>
    <bug_when>2012-03-07 22:12:22 -0800</bug_when>
    <thetext>The whatwg mailing list thread for the issue - 
http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-February/034929.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>593103</commentid>
    <comment_count>13</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-04-01 17:21:51 -0700</bug_when>
    <thetext>To paraphrase Ian&apos;s response, the spec requires the focus be dropped in this case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>593107</commentid>
    <comment_count>14</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2012-04-01 17:32:22 -0700</bug_when>
    <thetext>Also see https://bugs.webkit.org/show_bug.cgi?id=40338.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1295936</commentid>
    <comment_count>15</comment_count>
    <who name="Manuel Rego Casasnovas">rego</who>
    <bug_when>2017-04-10 02:22:43 -0700</bug_when>
    <thetext>It seems only Chrome behaves like this, and the spec text seems to support that behavior:
https://bugs.chromium.org/p/chromium/issues/detail?id=491828

Issues in other bugtrackers:
* Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=559561
* Edge: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/1308960/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1300753</commentid>
    <comment_count>16</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2017-04-24 17:24:01 -0700</bug_when>
    <thetext>&lt;rdar://problem/31801261&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>69791</attachid>
            <date>2010-10-05 08:34:56 -0700</date>
            <delta_ts>2010-10-05 08:34:56 -0700</delta_ts>
            <desc>Demo</desc>
            <filename>ie9-focus-display-none.html</filename>
            <type>text/html</type>
            <size>944</size>
            <attacher name="doum-ti-di-li-doom">duke_the_killer</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBYSFRNTCAxLjAgVHJhbnNpdGlvbmFs
Ly9FTiIgImh0dHA6Ly93d3cudzMub3JnL1RSL3hodG1sMS9EVEQveGh0bWwxLXRyYW5zaXRpb25h
bC5kdGQiPg0KPGh0bWwgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGh0bWwiIGxhbmc9
ImVuIj4NCjxoZWFkPg0KPG1ldGEgaHR0cC1lcXVpdj0iY29udGVudC10eXBlIiBjb250ZW50PSJ0
ZXh0L2h0bWw7IGNoYXJzZXQ9VVRGLTgiIC8+DQo8dGl0bGU+Rm9jdXMgcmVtYWlucyBvbiBoaWRk
ZW4gZWxlbWVudDwvdGl0bGU+DQoNCjxzY3JpcHQgdHlwZT0idGV4dC9qYXZhc2NyaXB0Ij4NCndp
bmRvdy5zZXRUa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