anein / angular2-trim-directive

the directive trims whitespaces from the end of an input text value.
MIT License
46 stars 26 forks source link

Cursor moves to end of email input on Safari on input event #65

Open StevenMeyer opened 3 years ago

StevenMeyer commented 3 years ago

Description If one tries to edit a text input's value from the middle (or start) of the value the cursor is moved to the end position for the next input. This is only on Safari web browser.

Reproduction steps

  1. Open the playground using Safari
  2. Enter a value (such as joe.bloggs@example.com)
  3. Move the cursor position to anywhere but the end (eg. before the @ symbol)
  4. Start typing more than one character

Expected outcome The new text should be entered at the cursor position and the cursor position should only move with the new input

Actual outcome The first character is entered at the cursor position. The cursor is moved to the end of the input.

StevenMeyer commented 3 years ago

This is a duplicate of #36, but is still happening for us.

StevenMeyer commented 3 years ago

It's a problem with type="email" input elements. According to the spec these inputs don't have setSelectionRange() available.

A solution could be to, for email inputs only:

If my organisation decides that temporarily using a fork is preferable to fixing our cause for needing trim I may submit this PR myself.

anein commented 3 years ago

That would be great!