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

onContentSizeChange on TextInput does not trigger in some cases #1339

Open
d4rky-pl opened this issue May 7, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@d4rky-pl
Copy link

commented May 7, 2019

The problem

When <TextInput /> has an explicitly set height (for example because we're implementing an auto-growing textarea) then onContentSizeChange is not being triggered if the content height is smaller than that container height.

How to reproduce
https://codesandbox.io/s/ll3j9pwrx7
https://snack.expo.io/Bkkv7CRi4

Expected behavior
onContentSizeChange is called again with the correct values

Environment (include versions). Did this work in previous versions?

  • React Native for Web (version): 0.11.2
  • React (version): 16.8.6
  • Browser: tested on Chrome

Additional context
The workaround I've used in my particular implementation:

  if (Platform.OS === 'web') {
    const node = this.input._node
    node.style.height = 'inherit'
    const height = node.scrollHeight
    node.style.height = `${height}px`
    this.setState({ height })
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.