-
-
Notifications
You must be signed in to change notification settings - Fork 364
fix(Select): make sure show the right display text #5806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -761,7 +761,7 @@ public void ItemClick_Ok() | |
| } | ||
|
|
||
| [Fact] | ||
| public void DefaultVirtualizeItemText_Ok() | ||
| public void DefaultVirtualizeItemText_Null() | ||
| { | ||
| var cut = Context.RenderComponent<Select<string>>(pb => | ||
| { | ||
|
|
@@ -776,12 +776,33 @@ public void DefaultVirtualizeItemText_Ok() | |
|
|
||
| var input = cut.Find(".form-select"); | ||
| Assert.Contains("value=\"3\"", input.OuterHtml); | ||
| } | ||
|
|
||
| cut.SetParametersAndRender(pb => | ||
| [Fact] | ||
| public async Task DefaultVirtualizeItemText_Ok() | ||
| { | ||
| var cut = Context.RenderComponent<Select<string>>(pb => | ||
| { | ||
| pb.Add(a => a.Items, new SelectedItem[] | ||
| { | ||
| new("1", "Test1"), | ||
| new("2", "Test2") | ||
| }); | ||
| pb.Add(a => a.Value, "3"); | ||
| pb.Add(a => a.IsVirtualize, true); | ||
| pb.Add(a => a.DefaultVirtualizeItemText, "Test3"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (testing): Suggest adding a test case for null CurrentValueAsString with DefaultVirtualizeItemText set. It would be beneficial to have a test case where Suggested implementation: [Fact]
public void DefaultVirtualizeItemText_WithNullCurrentValueAsString()
{
var cut = Context.RenderComponent<Select<string>>(pb =>
{
pb.Add(a => a.Items, new SelectedItem[]
{
new("1", "Test1"),
new("2", "Test2")
});
// set Value to null to simulate a null CurrentValueAsString
pb.Add(a => a.Value, null);
pb.Add(a => a.IsVirtualize, true);
pb.Add(a => a.DefaultVirtualizeItemText, "Test3");
});
// Assert that the default virtualize text appears in the markup when Value is null.
Assert.Contains("Test3", cut.Markup);
}Ensure that the CSS selectors used in the test (if any) are correct for your component. |
||
| }); | ||
|
|
||
| var input = cut.Find(".form-select"); | ||
| Assert.Contains("value=\"Test3\"", input.OuterHtml); | ||
|
|
||
| var items = cut.FindAll(".dropdown-item"); | ||
| Assert.Equal(2, items.Count); | ||
|
|
||
| var item = items[1]; | ||
| await cut.InvokeAsync(() => item.Click()); | ||
| input = cut.Find(".form-select"); | ||
| Assert.Contains("value=\"Test2\"", input.OuterHtml); | ||
| } | ||
|
|
||
| [Fact] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Review the update of default virtualized text after an item click.
Updating _defaultVirtualizedItemText on item click changes what is considered the default text. Ensure that this behavior is intended or consider renaming the field to better reflect its dynamic role.