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

Check if hiddenTextarea is in current body

Open mendelk opened this issue 5 years ago • 3 comments

In situations where the document.body was replaced, the check if hiddenTextarea.parentNode === null would return false even if in fact the new document.body had no current hiddenTextarea, thus requiring a new one to be appended. The new logic checks if !document.body.contains(hiddenTextarea), which should account for the current document.body.

An alternative solution would be to check if hiddenTextarea.isConnected, which is probably more performant. Unfortunately, this property is not present in IE.

Yet another solution which might be more performant at the expense of being more verbose, is to recursively check if hiddenTextarea.parentNode === null to confirm that it's in fact still in the current DOM tree.

Fixes #247

mendelk avatar Jul 28 '20 05:07 mendelk

💥 No Changeset

Latest commit: a43519c1f6996b2ddb5e4767e1ba86f2d2140ce1

Merging this PR will not cause any packages to be released. If these changes should not cause updates to packages in this repo, this is fine 🙂

If these changes should be published to npm, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Jul 28 '20 05:07 changeset-bot[bot]

I encountered this situation (using Turbolinks) and can confirm that this PR solves the problem in my case.

derrickreimer avatar Aug 04 '20 18:08 derrickreimer

@Andarist Is there anything I can do to help get this merged? I get that you've got lots of other things vying for your attention!

mendelk avatar Aug 13 '21 16:08 mendelk