Skip to content

Commit 5e40b2f

Browse files
committed
refactor(menu-item): add null check of the Id parameter
1 parent 0f8127f commit 5e40b2f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

docs/LumexUI.Docs.Client/Pages/Components/Dropdown/Examples/ColorsVariants.razor

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141

4242
@code {
4343
private ThemeColor _color = ThemeColor.Default;
44-
private MenuVariant _variant = MenuVariant.Solid;
4544

4645
private Task TriggerAsync( string id )
4746
{
@@ -57,7 +56,7 @@
5756
MenuVariant.Flat => Variant.Flat,
5857
MenuVariant.Shadow => Variant.Shadow,
5958
MenuVariant.Light => Variant.Light,
60-
_ => Variant.Solid
59+
_ => throw new NotSupportedException()
6160
};
6261
}
6362
}

src/LumexUI/Components/Menu/MenuItem.razor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ protected override void OnInitialized()
116116
/// <inheritdoc />
117117
protected override void OnParametersSet()
118118
{
119+
if( Id is null )
120+
{
121+
throw new InvalidOperationException(
122+
$"{GetType()} requires a value for the {nameof( Id )} parameter." );
123+
}
124+
119125
_disabled = Disabled || Menu.DisabledItems?.Contains( Id ) is true;
120126

121127
var menuItem = Styles.MenuItem.Style( TwVariant );

0 commit comments

Comments
 (0)