Skip to content

[EuiPopover] Should unmount immediately on parent unmount #4265

Closed as not planned

Description

@dej611

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.

popover_closing_slow

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:

popover_closing_slow_shadow

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:

Screenshot 2020-11-16 at 10 18 52

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.

Activity

  1. thompsongl commented on Nov 17, 2020

    @thompsongl
    Contributor

    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)

    Screen Cast 2020-11-17 at 12 35 54 PM

  2. dej611 commented on Nov 18, 2020

    @dej611
    ContributorAuthor

    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.

  3. chandlerprall commented on Nov 18, 2020

    @chandlerprall
    Contributor

    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.

  4. changed the title [-]Popover component should unmount immediately on parent unmount[/-] [+][EuiPopover] Should unmount immediately on parent unmount[/+] on Nov 19, 2020
  5. ogupte commented on Mar 3, 2021

    @ogupte

    This also seems to be same issue we're seeing with the sitewide search + Flyout with ownFocus={false} (elastic/kibana#90771)

  6. daveyholler commented on Mar 6, 2023

    @daveyholler
    Contributor

    @dej611 Are you aware if this is still a valid issue?
    cc: @ogupte

  7. added
    stale-issue
    on Jul 3, 2023
  8. removed
    stale-issue
    on Jul 3, 2023
  9. cee-chen commented on Oct 24, 2023

    @cee-chen
    Contributor

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions