[Webkit-unassigned] [Bug 191255] New: Setting input's value to the same value moves caret at end of input

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Nov 5 02:37:21 PST 2018


https://bugs.webkit.org/show_bug.cgi?id=191255

            Bug ID: 191255
           Summary: Setting input's value to the same value moves caret at
                    end of input
           Product: WebKit
           Version: Safari 12
          Hardware: Unspecified
                OS: macOS 10.14
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: HTML Editing
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: giovanni.piller at gmail.com
                CC: wenson_hsieh at apple.com

Created attachment 353841

  --> https://bugs.webkit.org/attachment.cgi?id=353841&action=review

Bug reproduction

Focusing at the beginning of an input, caret at position 0, then setting `input.value = input.value` will move caret position to the end of the input.

This is inconsistent with other browser's implementations (tested on Chrome 70.0.3538.77 and Firefox 63.0.1).
Also inconsistent with WebKit's <textarea> element, where setting `textarea.value = textarea.value` won't move the caret.

I've created a JSFiddle to give you an example. Also, attached a video with reproduction.

JSFiddle: https://jsfiddle.net/foavjy3n/2/ (code also pasted below)

/////////////////////////////////////////////

<main>
  <p>Start typing <strong>BEFORE</strong> "test".</p>
  <p>Focus will be moved at the end of the INPUT, while this won't happen for the TEXTAREA.</p>

  <div>
    <label for="input-text">Plain text input</label>
    <input id="input-text" type="text" value="test">
  </div>

  <div>
    <label for="textarea">Textarea</label>
    <textarea id="textarea">test</textarea>
  </div>
</main>

<script>
  function monitorValueFor(id) {
    const element = document.getElementById(id);

    element.addEventListener('input', ({ target }) => {
      target.value = target.value;
    });
  }

  monitorValueFor('input-text');
  monitorValueFor('textarea');
</script>

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20181105/12532866/attachment.html>


More information about the webkit-unassigned mailing list