You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[EuiPopover] Should unmount immediately on parent unmount #4265
In lens we have a layout with a flyout with a Drag and Drop are where a Popover can be toggled.
In order to handle automatic close of both flyout and popover there are 2 active EuiOutsideClickDetector which make sure both close on user click.
While the flyout disappear immediately, the popover has a nice fadeout animation which leads to a visual glitch in this scenario (see top left on flyout close), as its parent component gets unmounted before such animation is completed:
Because of this behaviour, the draggable element which is triggering the popover gets still referenced leading beautiful dnd to show a warning + error messages in the console:
I know it's a bit tricky scenarios, but it is currently implemented in Lens.
The only feasible solution found from the EUI outside world would be to wait a bit until the popover animation is completed before closing the flyout, but as suggested in the comment that solution is a bit flacky and it would be better to be addressed at the EUI level.
One proposed solution would be to immediately stop the animation and unmount the popover if it detect the parent component gets unmounted.
Spent some time investigating this and here's what I've found so far:
Haven't been able to reproduce the bug in a simpler environment
The flyout in question is not an EuiFlyout, but an approximation of EuiFlyout consisting of EuiFocusTrap, EuiOutsideClickDetector, and div[role="dialog"]
The popover should be closing on mouseDown but is not (all EuiPopoover[ownFocus=true] I can find close on mouseDown)
The bug only occurs when the KQL bar has focus (see gif below; not sure why the color is off)
From my experiments the bug can be even more subtle, as not immediately visible from a visual glitch, rather having side effects on other components.
For instance, when using Intervals => Add custom intervals => click on the first entry => Popover , clicking outside the flyout will not show a visible glitch but the console will still log the beautiful dnd warning/errors related to that.
At first glance, we might be able to band-aid this by not repositioning the popover given some heuristic - anchor bounds dimensions are 0x0, not present in the document, etc.
The root cause, however, is less clear to me. If the anchor is unmounted, the popover component is unmounted. There isn't a way to tell React "don't delete this yet". Maybe there's a difference because the popover panel is portalled to another place in the DOM, yet EuiPortal's componentWillUnmount calls this.portalNode.parentNode.removeChild(this.portalNode); which leaves React out of the equation for that bit.
I'd be interest in the sequence of console.logs tracking:
render of the popover's owner (the component returning EuiPopover) + the value of isOpen
EuiPortal::componentWillUnmount
EuiPopover::positionPopover (and maybe the stack trace here)
For whoever gets to this first: Kibana pre-bundles EUI into packages/kbn-ui-shared-deps/target/[email protected] and changes to that file apply when you refresh the page - no compilation/optimization step to wait for.
changed the title [-]Popover component should unmount immediately on parent unmount[/-][+][EuiPopover] Should unmount immediately on parent unmount[/+]on Nov 19, 2020
Activity
thompsongl commentedon Nov 17, 2020
Spent some time investigating this and here's what I've found so far:
dej611 commentedon Nov 18, 2020
From my experiments the bug can be even more subtle, as not immediately visible from a visual glitch, rather having side effects on other components.
For instance, when using
Intervals=>Add custom intervals=> click on the first entry => Popover , clicking outside the flyout will not show a visible glitch but the console will still log the beautiful dnd warning/errors related to that.chandlerprall commentedon Nov 18, 2020
At first glance, we might be able to band-aid this by not repositioning the popover given some heuristic - anchor bounds dimensions are 0x0, not present in the document, etc.
The root cause, however, is less clear to me. If the anchor is unmounted, the popover component is unmounted. There isn't a way to tell React "don't delete this yet". Maybe there's a difference because the popover panel is portalled to another place in the DOM, yet EuiPortal's componentWillUnmount calls
this.portalNode.parentNode.removeChild(this.portalNode);which leaves React out of the equation for that bit.I'd be interest in the sequence of
console.logs tracking:isOpenFor whoever gets to this first: Kibana pre-bundles EUI into packages/kbn-ui-shared-deps/target/[email protected] and changes to that file apply when you refresh the page - no compilation/optimization step to wait for.
[-]Popover component should unmount immediately on parent unmount[/-][+][EuiPopover] Should unmount immediately on parent unmount[/+]ogupte commentedon Mar 3, 2021
This also seems to be same issue we're seeing with the sitewide search +
FlyoutwithownFocus={false}(elastic/kibana#90771)daveyholler commentedon Mar 6, 2023
@dej611 Are you aware if this is still a valid issue?
cc: @ogupte
cee-chen commentedon Oct 24, 2023
Closing this as wontfix / can't repro - please open a new issue if this is still occurring in Kibana, ideally with a minimum repro codesandbox