Use mutation events for injections mounts too
Created by: felixfbecker
#2909 used a mutation observer for code view detection, but still called the inject*
functions on every mutation event. It turns out ReactDOM.render()
is not idempotent and triggered mutation events in Firefox, resulting in an infinite loop of mutation events.
The solution is to only re-render the mounts when a node was added to the DOM that should contain a mount, which means the render only happens once.
To accomplish that, this PR changes all get*Mount
functions to receive a container. The mount getter needs to check if the mount belongs into the container, if yes get or create the mount inside, otherwise return null
.
The mount getters are then called with addedNodes
from mutation events.
This necessitates other changes:
- We can't use React context for telemetry anymore, see #3180 (closed). This refactors the webapp to use props instead (also renames
eventLogger
totelemetryService
for consistency / easier passing). - The
HoverOverlayContainer
component had unneeded code in it (portals, hover overlay mount container container) that I removed -
componentWillUnmount()
and handling Subscriptions was missing in some places
Fixes #3180 (closed) Fixes #3166 (closed)
Test plan:
-
GitHub -
GHE -
Gitlab -
Phabricator -
Bitbucket
x (Chrome, Firefox)