react-input-autosize icon indicating copy to clipboard operation
react-input-autosize copied to clipboard

Does not update when input element is hidden on first render

Open phiresky opened this issue 5 years ago • 0 comments

When the input element is hidden on first render (e.g. a parent element has display: none set), then the computed size of the sizer element is "auto" instead of "123px", and the input does not notice when it gets shown, it is only updated after it is rerendered

Somewhat hacky, but this can be fixed by adding a resize observer watching the size of the input

	if (this.input.current)
		new ResizeObserver(() => this.updateInputWidth()).observe(
			this.input.current,
		)

to the componentDidMount function

phiresky avatar Dec 09 '20 11:12 phiresky