Render/mount to a detached DOM node #4197
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changelog Entry
Fixed
Description
When rendering Web Chat to a detached DOM node, it should not break.
The following code should work.
We could not catch this during release testing as all of our samples and testing sites did not render Web Chat on a detached node.
Design
In our transcript fix (#4108), we started using
getClientRects()
to compute the bounding boxes.However, when Web Chat is rendered/mounted to a detached DOM node,
getClientRects()
will return an empty array. We assumed it always return an array with at least one instance.Thus,
getClientsRects()[0].bottom
would throw an exception saying it could not accessbottom
ofundefined
.We looked at our production codebase and found only
BasicTranscript.tsx
will callgetClientRects()
. We have protected all instances.Specific Changes
BasicTranscript.tsx
to protect allgetClientRects()
against rendering on detached DOM node4.15.1
as this is considered QFECHANGELOG.md
I have updated documentationReview Checklist
Accessibility reviewed (tab order, content readability, alt text, color contrast)Browser and platform compatibilities reviewedCSS styles reviewed (minimal rules, noz-index
)Documents reviewed (docs, samples, live demo)Internationalization reviewed (strings, unit formatting)package.json
andpackage-lock.json
reviewedSecurity reviewed (no data URIs, check for nonce leak)