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
<option> elements inserted dynamically during same diff as <select> don't get auto-selected #21453
Comments
@pgillett thanks for contacting us. Bind is a compiler feature and I believe for it to work with select it needs to be used in conjunction with options. @SteveSandersonMS might know better, but that's my guess. |
@pgillett Thanks for reporting this. HTML We handle most of these cases perfectly well and until your report, I thought we handled all the possible cases. However upon investigation I see we are missing support for the case where In a sense this is quite an easy bug to fix: we could just remove this line of code and it would work fine. However that opens up a design question: when there's no corresponding Tentatively I think the preferred design would be that we match up assigned Hopefully we can apply a fix for this as part of the 5.0 release. Until then, the best workaround would be to avoid having a separate component just to represent an individual |
@SteveSandersonMS based on your comment, it seems this might be a dupe of #21432 |
This does appear to be the same as what I found, but @SteveSandersonMS workaround would not apply as my options are already inlined.
I would agree with this. |
I think keeping the value and binding it when the option exists makes perfect sense. The value is the value, the select is just a lookup presentation of that value. If the value isn't in the lookup, the lookup should display the wrong value because the coder has it wrong. |
Issue
If I use a custom component for the option tag of a select, the initial bind doesn't seem to work. The selection is invalid and the component displays the top item.
From there on everything works as expected and binding is fine.
This is on server-side, have not tested WASM/client-side.
To reproduce
Code shows three components. An input field (purely to test binding), a select using the option tag, and a select using the custom option tag.
The 2nd select (custom option) incorrectly has item A highlighted.
And the custom MyOption component:
(Doesn't make any difference with a value parameter instead of attribute splatting)
ASP.NET Core version 3.1.201
The text was updated successfully, but these errors were encountered: