Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<SolutionDir>$(MSBuildThisFileDirectory)</SolutionDir>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>

<VersionFile>4.9.3</VersionFile>
<VersionPrefix>4.9.3</VersionPrefix>
<VersionFile>4.9.4</VersionFile>
<VersionPrefix>4.9.4</VersionPrefix>
<VersionSuffix></VersionSuffix>
<AssemblyVersion>$(VersionFile)</AssemblyVersion>
<FileVersion>$(VersionFile)</FileVersion>
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ These providers are used by associated services to display Toasts, Dialog boxes,
<FluentDialogProvider />
<FluentTooltipProvider />
<FluentMessageBarProvider />
<FluentMenuProvider />
```
> **note:** You can remove providers that are not used in your application.

Expand Down
117 changes: 117 additions & 0 deletions examples/Demo/Shared/Microsoft.FluentUI.AspNetCore.Components.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5917,6 +5917,19 @@
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenu.JSRuntime">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenu.ServiceProvider">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenu.MenuService">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenu.UseMenuService">
<summary>
Use IMenuService to create the menu, if this service was injected.
This value must be defined before the component is rendered (you can't change it during the component lifecycle).
Default, true.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenu.Anchor">
<summary>
Gets or sets the identifier of the source component clickable by the end user.
Expand Down Expand Up @@ -6002,6 +6015,18 @@
<param name="y"></param>
<returns></returns>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenu.DrawMenuWithoutService">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenu.DrawMenuWithService">
<summary />
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentMenu.UpdateMenuProviderAsync">
<summary />
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentMenu.SetOpenAsync(System.Boolean)">
<summary />
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentMenu.Dispose">
<summary>
Dispose this menu.
Expand Down Expand Up @@ -6055,6 +6080,98 @@
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentMenuItem.OnClickHandlerAsync(Microsoft.AspNetCore.Components.Web.MouseEventArgs)">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenuProvider.ClassValue">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenuProvider.StyleValue">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenuProvider.ServiceProvider">
<summary>
Gets or sets the injected service provider.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenuProvider.MenuService">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentMenuProvider.Menus">
<summary />
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentMenuProvider.OnInitialized">
<summary />
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.IMenuService.OnMenuUpdated">
<summary>
Action to be called when the menu is updated.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.IMenuService.Menus">
<summary>
Gets the list of menus.
</summary>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.IMenuService.Add(Microsoft.FluentUI.AspNetCore.Components.FluentMenu)">
<summary>
Add a menu to the list.
</summary>
<param name="menu"></param>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.IMenuService.Clear">
<summary>
Clear the list of menus.
</summary>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.IMenuService.Remove(Microsoft.FluentUI.AspNetCore.Components.FluentMenu)">
<summary>
Remove a menu from the list.
</summary>
<param name="menu"></param>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.IMenuService.RefreshMenuAsync(System.String,System.Boolean)">
<summary>
Refresh the menu.
</summary>
<param name="id"></param>
<param name="isOpen"></param>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.MenuService.OnMenuUpdated">
<summary>
<see cref="P:Microsoft.FluentUI.AspNetCore.Components.IMenuService.OnMenuUpdated" />
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.MenuService.Menus">
<summary>
<see cref="P:Microsoft.FluentUI.AspNetCore.Components.IMenuService.Menus" />
</summary>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.MenuService.Add(Microsoft.FluentUI.AspNetCore.Components.FluentMenu)">
<summary>
<see cref="M:Microsoft.FluentUI.AspNetCore.Components.IMenuService.Add(Microsoft.FluentUI.AspNetCore.Components.FluentMenu)" />
</summary>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.MenuService.Remove(Microsoft.FluentUI.AspNetCore.Components.FluentMenu)">
<summary>
<see cref="M:Microsoft.FluentUI.AspNetCore.Components.IMenuService.Remove(Microsoft.FluentUI.AspNetCore.Components.FluentMenu)" />
</summary>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.MenuService.Clear">
<summary>
<see cref="M:Microsoft.FluentUI.AspNetCore.Components.IMenuService.Clear" />
</summary>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.MenuService.Dispose">
<summary>
<see cref="M:Microsoft.FluentUI.AspNetCore.Components.IMenuService.Clear" />
</summary>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.MenuService.RefreshMenuAsync(System.String,System.Boolean)">
<summary>
<see cref="M:Microsoft.FluentUI.AspNetCore.Components.IMenuService.RefreshMenuAsync(System.String,System.Boolean)" />
</summary>
<param name="id"></param>
<param name="isOpen"></param>
<returns></returns>
</member>
<member name="T:Microsoft.FluentUI.AspNetCore.Components.FluentMessageBar">
<summary />
</member>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<FluentStack>

<FluentCard>
<p>Click this button to open a Menu.</p>
<FluentButton Id="btnOpenMenuProvider1"
Appearance="Appearance.Accent"
OnClick="@(() => open1 = !open1)">
Open menu
</FluentButton>

<!-- UseMenuService="false" -->
<FluentMenu UseMenuService="false"
Anchor="btnOpenMenuProvider1"
@bind-Open="open1"
VerticalThreshold="170">
<FluentMenuItem>Menu item 1</FluentMenuItem>
<FluentMenuItem>Menu item 2</FluentMenuItem>
</FluentMenu>
</FluentCard>

<FluentCard>
<p>Click this button to open a Menu.</p>
<FluentButton Id="btnOpenMenuProvider2"
Appearance="Appearance.Accent"
OnClick="@(() => open2 = !open2)">
Open menu
</FluentButton>

<!-- UseMenuService="true" (or undefined) -->
<FluentMenu UseMenuService="true"
Anchor="btnOpenMenuProvider2"
@bind-Open="open2"
VerticalThreshold="170">
<FluentMenuItem>Menu item 1</FluentMenuItem>
<FluentMenuItem>Menu item 2</FluentMenuItem>
</FluentMenu>
</FluentCard>

</FluentStack>

@code {
bool open1 = false;
bool open2 = false;
}
104 changes: 68 additions & 36 deletions examples/Demo/Shared/Pages/Menu/MenuPage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,37 @@
Fluent UI design system.
</p>

<div>
<div><strong>FluentMenuProvider</strong></div>
<p>
With version 4.9.4 of the library, we introduced a <code>FluentMenuProvider</code>. The <code>FluentMenu</code> component has been updated to use this provider.
The <code>&lt;FluentMenuProvider /&gt;</code> is a new component to be placed at the <b>bottom</b> of your HTML page (like the other <b>Providers</b>),
which renders all menus (and menu items) at the provider location in the HTML structure. This allows for menus to appear <b>on top</b> other components.
</p>
<p>
You can disable this feature by adding the <code>UseMenuService="false"</code> attribute.
In this case, the menu is drawn at the location of your HTML code.
</p>
</div>

<h2 id="example">Example</h2>

<DemoSection Title="Service provider" Component="@typeof(MenuServiceProviderExample)">
<p>
The <strong>first</strong> example contains the <code>UseMenuService="false"</code> attribute.
The menu is created where it is declared, which can pose encapsulation problems,
depending on the container used (in this case, a <code>FluentCard</code>).
</p>
<p>
The <strong>second</strong> example uses the <code>FluentMenuProvider</code> to display the menu.
In this case, the menu is generated at the end of the HTML page and attached to the button using the <code>Anchor</code> tag.
<bloquote>
It's mandatory to use a <code>Id</code> identifier on the clickable element
and an identical <code>Anchor</code> value on the menu, to link the two elements.
</bloquote>
</p>
</DemoSection>

<DemoSection Title="Default" Component="@typeof(SimpleMenuExample)"></DemoSection>

<DemoSection Title="Simple context menu" Component="@typeof(ContextMenuExample)"></DemoSection>
Expand All @@ -51,46 +80,49 @@

<DemoSection Title="With icons" Component="@typeof(MenuIcon)">
<Description>
<p>
When using <code>FluentIcon</code>s in a <code>FluentMenuItem</code>, you will run into issues with indentation when putting the icons in slots.
This problem originates from the following: (from <a href="https://www.fast.design/docs/components/menu#setup" rel="nofollow">https://www.fast.design/docs/components/menu#setup</a>):
</p>
<blockquote>
<p>
When using <code>FluentIcon</code>s in a <code>FluentMenuItem</code>, you will run into issues with indentation when putting the icons in slots.
This problem originates from the following: (from <a href="https://www.fast.design/docs/components/menu#setup" rel="nofollow">https://www.fast.design/docs/components/menu#setup</a>):</p>
<blockquote>
<p>
<code>fast-menu</code> applies <code>fast-menu-item</code>'s <code>startColumnCount</code> property based on an evaluation
of all of the <code>fast-menu-items</code> so the content text vertically aligns across all <code>fast-menu-items</code>.
If any <code>fast-menu-item</code> does not have a roll of <code>checkbox</code> or <code>radio</code> or the
<code>start</code> slot is not passed, <code>startColumnCount</code> is set to 0 which applies a <code>indent-0</code> class
to all the <code>fast-menu-item</code>s. If any <code>fast-menu-item</code> has a roll of <code>checkbox</code> or
<code>radio</code> or the <code>start</code> slot exists, <code>startColumnCount</code> is set to 1 which applies a
<code>indent-1</code> class to all the <code>fast-menu-item</code>s. Or if any <code>fast-menu-item</code> has a roll of
<code>checkbox</code> or <code>radio</code> and the <code>start</code> slot exists, <code>startColumnCount</code> is set to
2 which applies a <code>indent-2</code> class to all the <code>fast-menu-item</code>s.
</p>
</blockquote>
<p>
Because we are rendering the web components indirectly <code>fast-menu</code> doesn't know about the icons and their slots in the
<code>fast-menu-items</code> when it renders (they don't exist in the DOM yet) so it can't determine the <code>startColumnCount</code>.
<code>fast-menu</code> applies <code>fast-menu-item</code>'s <code>startColumnCount</code> property based on an evaluation
of all of the <code>fast-menu-items</code> so the content text vertically aligns across all <code>fast-menu-items</code>.
If any <code>fast-menu-item</code> does not have a roll of <code>checkbox</code> or <code>radio</code> or the
<code>start</code> slot is not passed, <code>startColumnCount</code> is set to 0 which applies a <code>indent-0</code> class
to all the <code>fast-menu-item</code>s. If any <code>fast-menu-item</code> has a roll of <code>checkbox</code> or
<code>radio</code> or the <code>start</code> slot exists, <code>startColumnCount</code> is set to 1 which applies a
<code>indent-1</code> class to all the <code>fast-menu-item</code>s. Or if any <code>fast-menu-item</code> has a roll of
<code>checkbox</code> or <code>radio</code> and the <code>start</code> slot exists, <code>startColumnCount</code> is set to
2 which applies a <code>indent-2</code> class to all the <code>fast-menu-item</code>s.
</p>
<p>
As a workaround, place the <code>FluentIcons</code> inside a <code>&lt;span slot="start"&gt;&lt;/span&gt;</code>
(or <code>&lt;span slot="end"&gt;&lt;/span</code>&gt; in the menu items. For example:
</p>
<CodeSnippet>&lt;FluentMenu&gt;
&lt;FluentMenuItem&gt;
Menu item 1
&lt;span slot="start" &gt;
</blockquote>
<p>
Because we are rendering the web components indirectly <code>fast-menu</code> doesn't know about the icons and their slots in the
<code>fast-menu-items</code> when it renders (they don't exist in the DOM yet) so it can't determine the <code>startColumnCount</code>.
</p>
<p>
As a workaround, place the <code>FluentIcons</code> inside a <code>&lt;span slot="start"&gt;&lt;/span&gt;</code>
(or <code>&lt;span slot="end"&gt;&lt;/span</code>&gt; in the menu items. For example:
</p>
<CodeSnippet>
&lt;FluentMenu&gt;
&lt;FluentMenuItem&gt;
Menu item 1
&lt;span slot="start" &gt;
&lt;FluentIcon Icon="Icons.Regular.Size16.Globe" Slot="start" Color="Color.Neutral" /&gt;
&lt;/span&gt;
&lt;span slot="end"&gt;
&lt;/span&gt;
&lt;span slot="end"&gt;
&lt;FluentIcon Icon="Icons.Regular.Size16.Globe" Slot="end" Color="Color.Neutral" /&gt;
&lt;/span&gt;
&lt;/FluentMenuItem&gt;
:
:</CodeSnippet>
<p>
The script gets triggered then and the icons render in the right place. You can leave the <code>Slot</code> parameter in
the <code>FluentIcon</code> but in this case it doesn't have to be there anymore.
</p>
&lt;/span&gt;
&lt;/FluentMenuItem&gt;
:
:
</CodeSnippet>
<p>
The script gets triggered then and the icons render in the right place. You can leave the <code>Slot</code> parameter in
the <code>FluentIcon</code> but in this case it doesn't have to be there anymore.
</p>
</Description>
</DemoSection>

Expand Down
1 change: 1 addition & 0 deletions examples/Demo/Shared/Shared/DemoMainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<FluentDialogProvider />
<FluentTooltipProvider />
<FluentKeyCodeProvider />
<FluentMenuProvider />

</div>
</FluentBodyContent>
Expand Down
1 change: 1 addition & 0 deletions examples/Demo/Shared/wwwroot/docs/CodeSetup.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ These providers are used by associated services to display Toasts, Dialog boxes,
<FluentDialogProvider />
<FluentTooltipProvider />
<FluentMessageBarProvider />
<FluentMenuProvider />
```
> **note:** You can remove providers that are not used in your application.
> **note:** If you get scrollbars in your application, move the providers up in the page elements hierarchy, for example into the `FluentBodyContent` component.
Expand Down
Loading