Skip to content

Cursor jumps when backspacing in a number input (with ShadowDOM) #11827

Closed
@YellowKirby

Description

@YellowKirby

Do you want to request a feature or report a bug?
bug

What is the current behavior?
Number inputs with decimal values in Chrome ShadowDOM do not maintain cursor position as user backspaces in the input field.

Super low-quality gif (sorry):

This issue appears to be similar to the problem here: #7359, but in this case it's only custom elements with a shadow root that exhibit the problem.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template for React 16: https://jsfiddle.net/Luktwrdm/, template for React 15: https://jsfiddle.net/hmbg7e9w/).

  1. Have a React component render a number input: <input type="number" />.
  2. Attach that React component as part of the ShadowDOM node of a custom element.
  3. Enter in some decimal value (e.g., 88.88) into the input.
  4. Slowly backspace in the input. As soon as the decimal point would be the last character, the decimal point is removed and the cursor position jumps to the beginning of the input.

Demo: https://jsfiddle.net/69z2wepo/94566/

What is the expected behavior?

The ShadowDOM case behaves like the other cases: when backspacing in the input, the cursor does not jump to the beginning of the input and the decimal point is not unexpectedly deleted.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React 16.2.0 + Chrome 62.0.3202.62 + OSX 10.12.6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions