question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question about Ant Design Overlay

See original GitHub issue

I am running into errors when working with ant design overlays, but am unable to pinpoint what the issue is, so I cannot reproduce the error in a demo repo.

The error I get is “Failed to add overlay to the container”, which is in line 333 of your overlay code file. if (_position is null && _recurenceGuard <= 10) //up to 10 attempts { Console.WriteLine($"Failed to add overlay to the container. Container: {Trigger.PopupContainerSelector}, trigger: {Trigger.Ref.Id}, overlay: {Ref.Id}. Awaiting and rerunning."); await Task.Delay(10); await AddOverlayToBody(overlayLeft, overlayTop); }

I’d like to understand why you decided to check up to 10 attempts for the position of an overlay and what can potentially trigger this error.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jessielam415commented, Dec 20, 2021

Hi, I have a workaround for the issue. Not sure if this is helpful for diagnosing what caused the issue.

For Ant design dropdown, the issue disappears when I create an empty trigger and instead use the Visible property to control whether the dropdown is visible.

Overlay Error code:

<Dropdown Trigger="@(new Trigger[] { Trigger.Click })" Placement=Placement.BottomCenter>
    <Overlay>
        <Menu SelectedKeys=@null>
            <MenuItem>
                <CustomMenuComponent1/>
            </MenuItem>
            <MenuItem>
                <CustomMenuComponent2/>
            </MenuItem>
            <MenuItem>
                <CustomMenuComponent3/>
            </MenuItem>
            <MenuItem>
                <CustomMenuComponent4/>
            </MenuItem>
        </Menu>
    </Overlay>

    <ChildContent>

        <Button> Username </Button>

    </ChildContent>
</Dropdown>

Fixed code that doesn’t cause error:

<Dropdown Trigger="@(new Trigger[] { })" Placement=Placement.BottomCenter OnClick="() => _dropdownVisible = !_dropdownVisible" Visible="_dropdownVisible">
    <Overlay>
        <Menu SelectedKeys=@null>
            <MenuItem>
                <CustomMenuComponent1/>
            </MenuItem>
            <MenuItem>
                <CustomMenuComponent2/>
            </MenuItem>
            <MenuItem>
                <CustomMenuComponent3/>
            </MenuItem>
            <MenuItem>
                <CustomMenuComponent4/>
            </MenuItem>
        </Menu>
    </Overlay>

    <ChildContent>

        <Button> Username </Button>

    </ChildContent>
</Dropdown>
@code {
    private bool _dropdownVisible = false;
}
0reactions
anranruyecommented, Dec 18, 2021

I mean you can download the whole project source code and build the project locally.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stay on the Page
Detail Overlay: Allows an overlay to present additional information when the user clicks or hovers over a link or section of content.
Read more >
FAQ
Here are the frequently asked questions about Ant Design and antd that you should look up before you ask in the community or...
Read more >
Modal
Asynchronously close a modal dialog when the OK button is pressed. For example, you can use this pattern when you submit a form....
Read more >
Tooltip
A simple text popup tip. When To Use. The tip is shown on mouse enter, and is hidden on mouse leave. The Tooltip...
Read more >
Progress
Display the current progress of an operation flow.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found