Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/Core/Components/Base/IFluentControlStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Microsoft.FluentUI.AspNetCore.Components;
* {
* if (firstRender && !string.IsNullOrEmpty(ControlStyle))
* {
* await JSRuntime.InvokeVoidAsync("Microsoft.FluentUI.Blazor.Utilities.Attributes.applyShadowStyle", Element, ".control", ControlStyle);
* await JSRuntime.InvokeVoidAsync("Microsoft.FluentUI.Blazor.Utilities.Attributes.applyShadowStyle", Element, ":host .control", ControlStyle);
* }
* }
*
Expand Down
3 changes: 2 additions & 1 deletion src/Core/Components/List/FluentSelect.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<CascadingValue Value="GetCurrentContext()" Name="ListContext" TValue="InternalListContext<TValue>" IsFixed="true">
<CascadingValue Value="(InternalListContext)GetCurrentContext()" Name="ListContextBase" TValue="InternalListContext" IsFixed="true">
<FluentField InputComponent="@this" ForId="@Id" Class="@ClassValue" Style="@StyleValue">
<fluent-dropdown id="@Id"
<fluent-dropdown @ref="@Element"
id="@Id"
appearance="@(Appearance.ToAttributeValue(isNull: ListAppearance.Outline, returnEmptyAsNull: true))"
placeholder="@Placeholder"
slot="@FluentSlot.FieldInput"
Expand Down
15 changes: 14 additions & 1 deletion src/Core/Components/List/FluentSelect.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.FluentUI.AspNetCore.Components;
/// A FluentSelect allows for selecting one or more options from a list of options.
/// </summary>
[CascadingTypeParameter(nameof(TValue))]
public partial class FluentSelect<TOption, TValue> : FluentListBase<TOption, TValue>
public partial class FluentSelect<TOption, TValue> : FluentListBase<TOption, TValue>, IFluentControlStyle, IFluentComponentElementBase
{
/// <summary />
public FluentSelect(LibraryConfiguration configuration) : base(configuration) { }
Expand Down Expand Up @@ -41,6 +41,14 @@ public FluentSelect(LibraryConfiguration configuration) : base(configuration) {
[Parameter]
public ListSize? Size { get; set; }

/// <inheritdoc cref="IFluentComponentElementBase.Element" />
[Parameter]
public ElementReference Element { get; set; }

/// <inheritdoc cref="IFluentControlStyle.ControlStyle" />
[Parameter]
public string? ControlStyle { get; set; }

/// <summary />
protected override async Task OnAfterRenderAsync(bool firstRender)
{
Expand All @@ -50,6 +58,11 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
// This method don't change the SelectedItems and Value properties.
var defaultText = Value is TOption option ? base.GetOptionText(option) : "";
await JSRuntime.InvokeFluentVoidAsync("Microsoft.FluentUI.Blazor.Components.Select.Initialize", Id, defaultText);

if (!string.IsNullOrEmpty(ControlStyle))
{
await JSRuntime.InvokeFluentVoidAsync("Microsoft.FluentUI.Blazor.Utilities.Attributes.applyShadowStyle", Element, ":host .control", ControlStyle);
}
Comment thread
dvoituron marked this conversation as resolved.
}

await base.OnAfterRenderAsync(firstRender);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)

if (!string.IsNullOrEmpty(ControlStyle))
{
await JSRuntime.InvokeVoidAsync("Microsoft.FluentUI.Blazor.Utilities.Attributes.applyShadowStyle", Element, ".control", ControlStyle);
await JSRuntime.InvokeVoidAsync("Microsoft.FluentUI.Blazor.Utilities.Attributes.applyShadowStyle", Element, ":host .control", ControlStyle);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Components/TextArea/FluentTextArea.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)

if (!string.IsNullOrEmpty(ControlStyle))
{
await JSRuntime.InvokeVoidAsync("Microsoft.FluentUI.Blazor.Utilities.Attributes.applyShadowStyle", Element, ".control", ControlStyle);
await JSRuntime.InvokeVoidAsync("Microsoft.FluentUI.Blazor.Utilities.Attributes.applyShadowStyle", Element, ":host .control", ControlStyle);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Components/TextInput/FluentTextInput.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)

if (!string.IsNullOrEmpty(ControlStyle))
{
await JSRuntime.InvokeVoidAsync("Microsoft.FluentUI.Blazor.Utilities.Attributes.applyShadowStyle", Element, ".control", ControlStyle);
await JSRuntime.InvokeVoidAsync("Microsoft.FluentUI.Blazor.Utilities.Attributes.applyShadowStyle", Element, ":host .control", ControlStyle);
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions tests/Core/Components/List/FluentSelectTests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,20 @@
Assert.Equal(expected, attribute);
}

[Fact]
public void FluentSelect_ControlStyle_AppliesStyleToInternalControl()
{
// Arrange and Act
Render(@<FluentSelect ControlStyle="color: red;" Items="@Digits" TOption="string" TValue="string" />);

// Assert
var invocation = JSInterop.VerifyInvoke("Microsoft.FluentUI.Blazor.Utilities.Attributes.applyShadowStyle");
Assert.Equal(3, invocation.Arguments.Count);
Assert.IsType<ElementReference>(invocation.Arguments[0]);
Assert.Equal(":host .control", invocation.Arguments[1]);
Assert.Equal("color: red;", invocation.Arguments[2]);
Comment thread
dvoituron marked this conversation as resolved.
}

[Theory]
[InlineData("1", 1, null)]
[InlineData("abc", 0, "The 'Unknown Bound Field' field is not valid.")]
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Components/Number/FluentNumberTests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@
var invocation = JSInterop.VerifyInvoke("Microsoft.FluentUI.Blazor.Utilities.Attributes.applyShadowStyle");
Assert.Equal(3, invocation.Arguments.Count);
Assert.IsType<ElementReference>(invocation.Arguments[0]);
Assert.Equal(".control", invocation.Arguments[1]);
Assert.Equal(":host .control", invocation.Arguments[1]);
Assert.Equal("color: red;", invocation.Arguments[2]);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Components/TextArea/FluentTextAreaTests.razor
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
var invocation = JSInterop.VerifyInvoke("Microsoft.FluentUI.Blazor.Utilities.Attributes.applyShadowStyle");
Assert.Equal(3, invocation.Arguments.Count);
Assert.IsType<ElementReference>(invocation.Arguments[0]);
Assert.Equal(".control", invocation.Arguments[1]);
Assert.Equal(":host .control", invocation.Arguments[1]);
Assert.Equal("color: red;", invocation.Arguments[2]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
var invocation = JSInterop.VerifyInvoke("Microsoft.FluentUI.Blazor.Utilities.Attributes.applyShadowStyle");
Assert.Equal(3, invocation.Arguments.Count);
Assert.IsType<ElementReference>(invocation.Arguments[0]);
Assert.Equal(".control", invocation.Arguments[1]);
Assert.Equal(":host .control", invocation.Arguments[1]);
Assert.Equal("color: red;", invocation.Arguments[2]);
}

Expand Down
Loading