<?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>196481</bug_id>
          
          <creation_ts>2019-04-01 20:36:47 -0700</creation_ts>
          <short_desc>Caret shows in the wrong location in RTL text fields</short_desc>
          <delta_ts>2023-07-27 12:33:16 -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>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></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="Simon Fraser (smfr)">simon.fraser</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>dbates</cc>
    
    <cc>mitz</cc>
    
    <cc>rniwa</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1523206</commentid>
    <comment_count>0</comment_count>
      <attachid>366466</attachid>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2019-04-01 20:36:47 -0700</bug_when>
    <thetext>Created attachment 366466
Testcase

Load the attached testcase, click in the input, and type the letter &apos;a&apos;. Note how the caret stays on the left side. Now type &apos;b&apos; Note how the letter was input on the right side, which is not where the caret shows.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1523207</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-04-01 20:38:10 -0700</bug_when>
    <thetext>&lt;rdar://problem/49507145&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1523209</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2019-04-01 20:38:38 -0700</bug_when>
    <thetext>Also, if you hit Command-Right arrow to move the caret to the end, and type, the text is inserted on the left side.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1523212</commentid>
    <comment_count>3</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-04-01 20:49:23 -0700</bug_when>
    <thetext>This is expected. We show the caret at where the next character whose directionality match that of the block direction.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1523213</commentid>
    <comment_count>4</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2019-04-01 20:51:54 -0700</bug_when>
    <thetext>The behavior doesn&apos;t make sense, and doesn&apos;t agree with Firefox. If I type a character, I expect it to get inserted where the caret is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1523214</commentid>
    <comment_count>5</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2019-04-01 20:54:38 -0700</bug_when>
    <thetext>It also doesn&apos;t match native text fields in RTL.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1523215</commentid>
    <comment_count>6</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-04-01 20:55:50 -0700</bug_when>
    <thetext>(In reply to Simon Fraser (smfr) from comment #5)
&gt; It also doesn&apos;t match native text fields in RTL.

Yeah, indeed. It looks like NSTextView has changed its behavior at some point in the past. Note that Firefox&apos;s behavior is irrelevant here because each browser implements its own bidi behavior in this regard, and we really want to match the platform convention.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1523216</commentid>
    <comment_count>7</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2019-04-01 20:56:39 -0700</bug_when>
    <thetext>Oh, I guess the difference is whether I&apos;m actually entering characters in an RTL language. If I type Hebrew, it works as expected. If I type English, it does not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1523217</commentid>
    <comment_count>8</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2019-04-01 20:59:11 -0700</bug_when>
    <thetext>Typing &quot;1234&quot; and moving the caret around shows that we don&apos;t match the OS.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1523218</commentid>
    <comment_count>9</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-04-01 20:59:22 -0700</bug_when>
    <thetext>(In reply to Simon Fraser (smfr) from comment #7)
&gt; Oh, I guess the difference is whether I&apos;m actually entering characters in an
&gt; RTL language. If I type Hebrew, it works as expected. If I type English, it
&gt; does not.

Yeah, it looks like NSTextView decides the caret location based on the last character being typed.

Implementing the new NSTextView behavior is going to be a massive undertaking.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1523219</commentid>
    <comment_count>10</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-04-01 21:01:04 -0700</bug_when>
    <thetext>(In reply to Simon Fraser (smfr) from comment #8)
&gt; Typing &quot;1234&quot; and moving the caret around shows that we don&apos;t match the OS.

Numbers are tricky because they&apos;re weakly LTR. Try typing numbers after Hebrew / Arabic.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1968497</commentid>
    <comment_count>11</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2023-07-27 12:33:16 -0700</bug_when>
    <thetext>This is reproducible in WebKit ToT (266363@main) and Chrome Canary 117 as well. Only Firefox Nightly 117 show &apos;caret&apos; properly on the right side while typing.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>366466</attachid>
            <date>2019-04-01 20:36:47 -0700</date>
            <delta_ts>2019-04-01 20:36:47 -0700</delta_ts>
            <desc>Testcase</desc>
            <filename>just-a-text-input.html</filename>
            <type>text/html</type>
            <size>217</size>
            <attacher name="Simon Fraser (smfr)">simon.fraser</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+Cgo8aHRtbD4KPGhlYWQ+CiAgICA8c3R5bGU+CiAgICAgICAgaW5wdXQg
ewogICAgICAgICAgICBtYXJnaW46IDEwMHB4OwogICAgICAgICAgICBmb250LXNpemU6IDI0cHQ7
CiAgICAgICAgICAgIGRpcmVjdGlvbjogcnRsOwogICAgICAgIH0KICAgIDwvc3R5bGU+CjwvaGVh
ZD4KPGJvZHk+CjxpbnB1dCB0eXBlPSJ0ZXh0Ij4KPC9ib2R5Pgo8L2h0bWw+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>