<?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>224425</bug_id>
          
          <creation_ts>2021-04-12 02:12:23 -0700</creation_ts>
          <short_desc>setSelectionRange() on blur re-focuses input element</short_desc>
          <delta_ts>2021-04-13 01:49:40 -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>HTML Editing</component>
          <version>Safari 14</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</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="Cetin Sert">apple</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>akeerthi</cc>
    
    <cc>megan_gardner</cc>
    
    <cc>rniwa</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1749161</commentid>
    <comment_count>0</comment_count>
    <who name="Cetin Sert">apple</who>
    <bug_when>2021-04-12 02:12:23 -0700</bug_when>
    <thetext>See https://stackoverflow.com/questions/67055218/set-input-caret-position-on-blur-in-safari-without-refocusing-input

This is unique to Safari.

Is it possible to match the behavior of other browsers?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1749162</commentid>
    <comment_count>1</comment_count>
    <who name="Cetin Sert">apple</who>
    <bug_when>2021-04-12 02:16:11 -0700</bug_when>
    <thetext>In https://stackoverflow.com/questions/67055218/set-input-caret-position-on-blur-in-safari-without-refocusing-input (link to minimal playground test)

Safari is the only browser where &apos;setSelectionRange&apos; interferes with blur (focus loss/change)
  &apos;setSelectionRange&apos; traps the user into &apos;#a&apos; in Safari with no way out!
  &apos;selectionStart &gt; 0&apos; that I have added helps one escape on second attempt.

Is it possible to make &apos;setSelectionRange&apos; behave like other browsers i.e. not interrupt / mess with &apos;blur&apos; / &apos;focus loss/change&apos;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1749553</commentid>
    <comment_count>2</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2021-04-12 23:24:17 -0700</bug_when>
    <thetext>This is behaving correctly. In WebKit, focus follows selection so if you modify selection, then the focus will be moved there.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1749586</commentid>
    <comment_count>3</comment_count>
    <who name="Cetin Sert">apple</who>
    <bug_when>2021-04-13 01:30:08 -0700</bug_when>
    <thetext>Mr. Niwa!

Thank you for your reply.

I have sent a pull request to Mozilla/PDF.js to switch from &apos;setSelectionRange(0, 0)&apos; to &apos;scrollLeft = 0&apos; and have long patched it in my own project. We can consider this issue resolved if WebKit project does not deem it necessary to match &apos;setSelectionRange(0, 0)&apos; behavior with other browsers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1749587</commentid>
    <comment_count>4</comment_count>
    <who name="Cetin Sert">apple</who>
    <bug_when>2021-04-13 01:31:01 -0700</bug_when>
    <thetext>See https://github.com/mozilla/pdf.js/pull/13232 for more details.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1749594</commentid>
    <comment_count>5</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2021-04-13 01:49:40 -0700</bug_when>
    <thetext>(In reply to Cetin Sert from comment #3)

&gt; I have sent a pull request to Mozilla/PDF.js to switch from
&gt; &apos;setSelectionRange(0, 0)&apos; to &apos;scrollLeft = 0&apos; and have long patched it in my
&gt; own project. We can consider this issue resolved if WebKit project does not
&gt; deem it necessary to match &apos;setSelectionRange(0, 0)&apos; behavior with other
&gt; browsers.

Yeah, I saw that :) Thanks for reporting the bug anyway.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>