fluentui-blazor: fix: FluentSelect does not work inside FluentDataGrid
🐛 Bug Report
When using FluentSelect inside FluentDataGrid dropdown is not shown.
💻 Repro or Code Sample
Based on these examples:
https://brave-cliff-0c0c93310.azurestaticapps.net/SelectPage
https://brave-cliff-0c0c93310.azurestaticapps.net/DatagridPage
I would also like some better examples working with enum values and select. I had to write my own code but I think this should be documented better. Added MatSelectItem as example since it works with FluentDataGrid. Select works fine with Enum when not used in FluentDataGrid
<p>
<MatSelectItem @bind-Value="@threatDto.Severity" Label="Severity" Items="@SeverityValues" FullWidth="true" Required="true">
</MatSelectItem>
</p>
<p>
<FluentSelect @bind-Value="@threatDto.Severity" Options="@SeverityOptionList" Required="true">
</FluentSelect>
</p>
<FluentDataGrid id="ExternalLinksGrid" RowsData=RowsGrid1 ColumnDefinitions=ExternalLinkColumns GridTemplateColumns="1fr 1fr" TItem=ExternalLink Context="tableRowContext">
<RowItemTemplate>
<FluentDataGridRow>
<FluentDataGridCell GridColumn=1>
<FluentTextField @bind-Value=@tableRowContext.Link></FluentTextField>
</FluentDataGridCell>
<FluentDataGridCell GridColumn=2>
<FluentSelect @bind-Value="@tableRowContext.LinkType" Options="@LinkTypeOptionList" Required="true">
</FluentSelect>
</FluentDataGridCell>
<FluentDataGridCell GridColumn=3>
<MatSelectItem @bind-Value="@tableRowContext.LinkType" Label="LinkType" Items="@LinkTypeValues" Required="true">
</MatSelectItem>
</FluentDataGridCell>
</FluentDataGridRow>
</RowItemTemplate>
</FluentDataGrid>
public List<ColumnDefinition<ExternalLink>> ExternalLinkColumns = new();
List<Severity?> SeverityValues = Enum.GetValues(typeof(Severity)).Cast<Severity?>().Where(x => x != Severity.None).ToList();
List<LinkType?> LinkTypeValues = Enum.GetValues(typeof(LinkType)).Cast<LinkType?>().Where(x => x != LinkType.None).ToList();
List<Option<Severity?>> SeverityOptionList = Enum.GetValues(typeof(Severity)).Cast<Severity?>().Where(x => x != Severity.None).Select(x => new Option<Severity?> { Key = x.Value, Value = x.Value }).ToList();
List<Option<LinkType?>> LinkTypeOptionList = Enum.GetValues(typeof(LinkType)).Cast<LinkType?>().Where(x => x != LinkType.None).Select(x => new Option<LinkType?> { Key = x, Value = x }).ToList();
List<ExternalLink> RowsGrid1 = new()
{
new ExternalLink(){ Link = "123", LinkType = LinkType.JiraRisk},
new ExternalLink(){ Link = "12345", LinkType = LinkType.OtherHyperlink},
};
protected override void OnInitialized()
{
ExternalLinkColumns.Add(new ColumnDefinition<ExternalLink>("Link", x => x.Link));
ExternalLinkColumns.Add(new ColumnDefinition<ExternalLink>("Link Type", x => x.LinkType));
ExternalLinkColumns.Add(new ColumnDefinition<ExternalLink>("Link Type MatSelectItem", x => x.LinkType));
}
Classes:
[Required, EnumDataType(typeof(Severity))]
public Severity? Severity { get; set; }
public class ExternalLink : Entity
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[Required]
[MaxLength(2048)]
public string Link { get; set; }
[Required, EnumDataType(typeof(LinkType))]
public LinkType? LinkType { get; set; }
}
public enum LinkType
{
None = 0,
OtherHyperlink = 1,
JiraIssue = 2,
JiraRisk = 3,
}
🤔 Expected Behavior
Should render drop down on click
😯 Current Behavior
No drop down is visible
💁 Possible Solution
🔦 Context
I can not use Fluent UI alone
🌍 Your Environment
- OS & Device: Windows
- Browser Chrome
- .NET and FAST Version .NET 6, Microsoft.Fast.Components.FluentUI 1.5.1 @fluentui/web-components 2.5.4
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 18 (10 by maintainers)
I believe this is an issue in the underlying web components. Have raised an issue there,
@ehsangfl More info here: https://learn.microsoft.com/en-us/aspnet/core/blazor/components/css-isolation?view=aspnetcore-7.0
Hi,
You need to add an isolated css file to your component and then target the listbox part of the select. Something like