<?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>138816</bug_id>
          
          <creation_ts>2014-11-17 17:31:30 -0800</creation_ts>
          <short_desc>:active behavior for touch depends on the presence of touch event handlers</short_desc>
          <delta_ts>2026-01-20 19:49:17 -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>UI Events</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>iOS 8.1</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <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="Rick Byers">rbyers</reporter>
          <assigned_to name="Abrar Rahman Protyasha">a_protyasha</assigned_to>
          <cc>karlcow</cc>
    
    <cc>linma</cc>
    
    <cc>vasko.dinkov</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1049367</commentid>
    <comment_count>0</comment_count>
    <who name="Rick Byers">rbyers</who>
    <bug_when>2014-11-17 17:31:30 -0800</bug_when>
    <thetext>Mobile Safari applies :active on touchstart and clears it on touchend.  This has some surprising consequences including:
 - A page with no touch event handlers doesn&apos;t get :active effects at all
 - A button with an :active effect will be triggered while scrolling over top of it (even though native platform convention is not to trigger active effects in such cases)

I changed this for chromium back in 2012 (see bug 96060 and http://crbug.com/133928).  Basically we set :active after a short delay when tap starts (what we call &quot;GestureShowPress&quot;), and clear it when a tap completes or is aborted (but we may also delay this to ensure :active is shown long enough to be visible when the user taps quickly).

What do you think, is it perhaps worth changing Safari to do something more rational here?  I&apos;m open to changing chromium again if we can come up with a model we agree is better.  One thing I don&apos;t like about our current model is that it&apos;s difficult to implement the same behavior from JS (unlike IE and Safari, there are no DOM events associated directly with the application and removal of :active for touch).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1049368</commentid>
    <comment_count>1</comment_count>
    <who name="Benjamin Poulain">benjamin</who>
    <bug_when>2014-11-17 17:34:55 -0800</bug_when>
    <thetext>Thanks for filing this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1155408</commentid>
    <comment_count>2</comment_count>
    <who name="Vasil Dinkov">vasko.dinkov</who>
    <bug_when>2016-01-14 02:30:46 -0800</bug_when>
    <thetext>In the docs we have this:

https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariWebContent/AdjustingtheTextSize/AdjustingtheTextSize.html

-------
You can also use the -webkit-tap-highlight-color CSS property &gt;&gt;&gt;in combination with setting a touch event&lt;&lt;&lt; to configure buttons to behave similar to the desktop. On iOS, mouse events are sent so quickly that the down or active state is never received. Therefore, the :active pseudo state is triggered only when there is a touch event set on the HTML element—for example, when ontouchstart is set on the element as follows:

&lt;button class=&quot;action&quot; ontouchstart=&quot;&quot; style=&quot;-webkit-tap-highlight-color: rgba(0,0,0,0);&quot;&gt;Testing Touch on iOS&lt;/button&gt;
Now when the button is tapped and held on iOS, the button changes to the specified color without the surrounding transparent gray color appearing.
-------

Currently in iOS (just confirmed in 8.1 but I believe it&apos;s the same in 9), when any touch* event is set to the document (or any parent container) all child elements are also affected and start showing the :hover/:active styles immediately if we touch them even if we just want to scroll the page. This can be quite annoying on specific pages where :hover/:active styles are applied on big elements and even more when transitions, etc. are used (example: scroll to the footer of http://phonegap.com/ and then try scrolling the page up by touching any of the big white links). This issue affects large amount of websites and popular frameworks like jQuery mobile, etc.

I don&apos;t see any logic why setting any touch* event handler to an element would trigger this behavior change. This looks more like an actual documented hack. It would have been much better if, for example, a vendor prefixed -webkit-* CSS property was introduced for the purpose instead.

IMHO it should be fixed like in Chrome/Android with the timeout logic Rick Byers describes above. According to my testing it works really well the way they&apos;ve implemented it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1921319</commentid>
    <comment_count>3</comment_count>
    <who name="">linma</who>
    <bug_when>2022-12-22 01:07:21 -0800</bug_when>
    <thetext>Here is a simple html that shows the problem.

&lt;html&gt;
&lt;style&gt;
  button {
    -webkit-tap-highlight-color: transparent;
  }
  button:active {
    background-color: red;
  }
&lt;/style&gt;
&lt;body&gt;
  &lt;button&gt;Button&lt;/button&gt;
&lt;/body&gt;
&lt;/html&gt;

On iOS, the button doesn&apos;t become red when pressed. All other platforms handles :active properly, Safari on iOS is alone in this behaviour.

Out of curiosity, is this bug still being considered?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2058713</commentid>
    <comment_count>4</comment_count>
    <who name="Rick Byers">rbyers</who>
    <bug_when>2024-09-09 13:37:09 -0700</bug_when>
    <thetext>Verified this still reproduces in iOS 17.6.1. Simple repro: https://output.jsbin.com/danijir

It&apos;s a decade later and one of the most basic features of the web on mobile (UI states responding to touch) still isn&apos;t standards compliant in WebKit. https://html.spec.whatwg.org/multipage/semantics-other.html#selector-active

Unassigning from Benjamin since AFAIK he doesn&apos;t work on WebKit anymore. Perhaps someone else wants to pick up this longstanding strange quirk in WebKit?</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>