-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Server-side blazor : <select> value is bound after being rendered #12667
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
Comments
I came across the same issue when I use
The checkbox is not checked on UI when I load the page. I am using preview 6 and I didn't check other versions. |
@hongkuancn Can you provide more details for the issue? Is the checkbox not checked during prerendering, is it not checked in reaction to the event handler? |
@hongkuancn
They both work with preview 7 (and no rendering issue like with the |
@glacasa Ok, so this seems like a prerendering issue, where the default value is not populated properly and gets fixed once its bound. |
@javiercn @rynowak We need to make a decision about whether (or perhaps more reasonably, how) to support this. It's nontrivial so might end up in 3.1. The problem is that The extra big problem for prerendering is that the block of Perhaps a cleaner solution would involve changing the Razor compiler so that it specifically forbids |
Will this change allow |
Are there meaningful and valid use cases |
Yes, it's what happens by default if your
We shouldn't assume the My suggestion above doesn't rely on |
Ah, I think I misinterpreted what you wrote. So if we changed the markup-block pass to bail out of a |
Yes. I don't recall precisely how the markup-block pass works, but it would need to ensure that an I expect it has to be triggered at the level of the |
The pass works top-down-bottom-up, so we'd just prevent recursion into a |
OK
Not in JS, but in the prerendering logic (C#) |
Done in #12996 and dotnet/razor#952 |
if anyone else found this issue searching for why their custom StateHasChanged-based binding wasn't working - render your selection using |
When I want to display a
select
tag with its value bound to a property, the select is rendered with the value not bound (first item selected), the correct option is then selected immediately.To reproduce, on the default Blazor template, I replaced the Counter.razor with this :
When we go to this page and reload, we can briefly see the "0" before the "1" in the
select
.The
input
is bound immediately.I don't see this happens when navigating to the page, but it happens when I press F5 to reload the page.
I have this behavior in preview 7, I didn't notice it in previous versions.
The text was updated successfully, but these errors were encountered: