microsoft / fluentui-blazor

Microsoft Fluent UI Blazor components library. For use with ASP.NET Core Blazor applications
https://www.fluentui-blazor.net
MIT License
3.74k stars 359 forks source link

fix: Scrollbars appear when opening a FluentMenu #2736

Closed JamesNK closed 1 hour ago

JamesNK commented 1 day ago

πŸ› Bug Report

There was a regression when moving from 4.9.3 to 4.10.1. Horizontal scrollbars appear when opening a FluentMenu.

Before: menu-scrollbars-before

After: menu-scrollbars-after

πŸ’» Repro or Code Sample

This was the change that introduces the regression: https://github.com/dotnet/aspire/pull/5670

Control on the page with the issue: https://github.com/dotnet/aspire/blob/f7f20e4c12dafa5b4b50c2b42f31cc2b1327fa37/src/Aspire.Dashboard/Components/Controls/AspireMenuButton.razor

πŸ€” Expected Behavior

No scroll bars.

😯 Current Behavior

Scroll bars appear.

πŸ’ Possible Solution

πŸ”¦ Context

🌍 Your Environment

dvoituron commented 1 day ago

Probably caused by the position of the <FluentMenuProvider /> which should be in an HTML section containing a overflow-y. Is it possible in your code?

You can disable the usage of this Provider by adding the UseMenuService="false" attribute. In this case, the menu is drawn at the location of your HTML code.

JamesNK commented 1 day ago

Is being an a section with overflow: auto ok?

~I tested more and found the scrollbars only appear when the browser is zoomed in, e.g. 110% size.~

JamesNK commented 1 day ago

I tested more and the issue only happens when the menu is close to the edge of the page. I guess going from 110% to 100% zoom above happened to move the menu far enough way for the issue not to happen.

menu-scrollbars-edge

vnbaaij commented 16 hours ago

So this can be closed?

JamesNK commented 14 hours ago

No. Scroll bars shouldn’t be appearing. The menu isn’t going off the edge of the page.

dvoituron commented 5 hours ago

Have you tried adding <FluentMenu UseMenuService=β€˜ false’ /> to revert to the previous usage?

JamesNK commented 5 hours ago

Yes: https://github.com/dotnet/aspire/pull/6039. But it is a temporary fix because the menu can be hidden by splitter areas again.

We need fluent menu provider but not have it add scroll bars.

dvoituron commented 4 hours ago

Yes: dotnet/aspire#6039. But it is a temporary fix because the menu can be hidden by splitter areas again.

We need fluent menu provider but not have it add scroll bars.

OK. Let me take a look

dvoituron commented 4 hours ago

The problem is that the body allows overflow, and with the new FluentMenuProvider, a side effect may be the display of this scroll bar.

You can solve that adding this code in the app.css file

body, .body {
    overflow: hidden;
}

I haven't seen a problem disabling scrollbars in body, as it seems that a layout div adds scrollbars if necessary.

dvoituron commented 3 hours ago

I've found another way to avoid displaying this body scrollbar: using display: fixed. I will create a PR to include these styles by default in the FluentUI Blazor library, but in the meantime, you can use it.

<div style="position: fixed; bottom: 0;">
    <FluentMenuProvider />
</div>
JamesNK commented 2 hours ago

Thanks, that works.