Skip to content

Cursor jumps to end of input when inputValue is a controlled prop #217

@robin-drexler

Description

@robin-drexler
  • downshift version: 1.11.0
  • node version: 6.9 (and codesadbox.io, could not find out, what they're using)
  • npm (or yarn) version: yarn 1.1.0 (and whatever codesandbox.io uses)

Problem description:

  • Visit this codesandbox
  • type text
  • move cursor to the left
  • type a letter
  • the letter will be added at the correct position, but the cursor will move to the end of the input instead of staying where you have typed

Relevant code or config

class Demo extends React.Component {
  state = {
    inputValue: ""
  };

  render() {
    return (
      <div>
        <Downshift
          onStateChange={data => {
            return (
              data.hasOwnProperty("inputValue") &&
              this.setState({ inputValue: data.inputValue })
            );
          }}
          inputValue={this.state.inputValue}
        >
          {({ getInputProps }) => (
            <div>
              <input {...getInputProps()} />
            </div>
          )}
        </Downshift>
      </div>
    );
  }
}

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