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] multiLine TextField loses cursor position on height change #4257

Closed
jamesbillinger opened this issue May 13, 2016 · 1 comment
Closed
Labels
bug 🐛 Something doesn't work component: TextareaAutosize The React component.

Comments

@jamesbillinger
Copy link

A multiLine textfield (EnhancedTextarea) moves the cursor to the end of the field when a setState is called. Specifically, if you're working in the middle of a large block of text and you make a change which results in the height of the textarea changing, the cursor will move to the end of the field.

If I comment out the setState call in syncHeightWithShadow the problem disappears. I'm sure this function is needed...not sure why it's losing cursor position.

    key: 'syncHeightWithShadow',
    value: function syncHeightWithShadow(newValue, event) {
      var shadow = this.refs.shadow;

      if (newValue !== undefined) {
        shadow.value = newValue;
      }

      var newHeight = shadow.scrollHeight;

      if (this.props.rowsMax >= this.props.rows) {
        newHeight = Math.min(this.props.rowsMax * rowsHeight, newHeight);
      }

      newHeight = Math.max(newHeight, rowsHeight);

      if (this.state.height !== newHeight) {
        /*this.setState({
          height: newHeight
        });*/

        if (this.props.onHeightChange) {
          this.props.onHeightChange(event, newHeight);
        }
      }
    }

I'm using version 0.15.0-beta.2. I did not test on 0.15.0, but I looked through the changes to this file and I didn't see anything related.

Tested in Chrome and Firefox

oephrosinin added a commit to oephrosinin/material-ui that referenced this issue May 24, 2016
@mpontikes mpontikes mentioned this issue Aug 5, 2016
13 tasks
@oliviertassinari oliviertassinari added the component: text field This is the name of the generic UI component, not the React module! label Dec 18, 2016
@oliviertassinari oliviertassinari changed the title multiLine TextField loses cursor position on height change [TextField] multiLine TextField loses cursor position on height change Dec 18, 2016
@oliviertassinari
Copy link
Member

Fixed by #7006.

@oliviertassinari oliviertassinari added the bug 🐛 Something doesn't work label Jul 28, 2017
@oliviertassinari oliviertassinari added component: TextareaAutosize The React component. and removed component: text field This is the name of the generic UI component, not the React module! labels Apr 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: TextareaAutosize The React component.
Projects
None yet
Development

No branches or pull requests

2 participants