Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextField cursor moves to end if multiline #4502

Closed
morenoh149 opened this issue Jun 15, 2016 · 3 comments
Closed

TextField cursor moves to end if multiline #4502

morenoh149 opened this issue Jun 15, 2016 · 3 comments
Labels
component: TextareaAutosize The React component.

Comments

@morenoh149
Copy link

morenoh149 commented Jun 15, 2016

Problem description

After you give a multiline TextField focus. The first call to onChange causes the change to be made and the cursor skips to the end of the input.

Steps to reproduce

import React from 'react';
import TextField from 'material-ui/TextField';

export default class TextFieldExampleControlled extends React.Component {

  constructor(props) {
    super(props);

    this.state = {
      value: 'Property Value',
    };
  }

  handleChange = (event) => {
    this.setState({
      value: event.target.value,
    });
  };

  render() {
    return (
      <div>
        <TextField
          id="text-field-controlled"
          value={this.state.value}
          onChange={this.handleChange}
          fullWidth
          multiLine
          rows={10}
        />
      </div>
    );
  }
}

Versions

  • Material-UI: 0.15.0
  • React: 15.1.0
  • Browser: chrome 51

The closest thing I could find in the code is a call to handleInputFocus which may be assuming the cursor should be at the end of the input, or by giving the field focus the browser automatically places the cursor at the end? not sure.

@jasan-s
Copy link

jasan-s commented Jun 22, 2016

Try
<TextField autoFocus = {true} />

@morenoh149
Copy link
Author

morenoh149 commented Jun 22, 2016

@jasan-s nope doesn't change the behavior. To be more specific the TextField resides within a Dialog. And the first time it's interacted with is after the area has been populated with text. The user then focuses into the TextField to change the default message and then the cursor jumps to the end of the message after the first keypress. Afterwards, and after multiple relaunches, editing the TextField works normally.

@mpontikes
Copy link

#4430 seems very related

@mpontikes mpontikes mentioned this issue Aug 5, 2016
13 tasks
@aahan96 aahan96 closed this as completed Aug 17, 2016
@oliviertassinari oliviertassinari added the component: TextareaAutosize The React component. label Apr 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: TextareaAutosize The React component.
Projects
None yet
Development

No branches or pull requests

5 participants