Skip to content

Blazor component: strange @attributes behavior #27932

Answered by SteveSandersonMS
pos777 asked this question in Q&A
Discussion options

You must be logged in to vote

It's up to the receiving component's SetParametersAsync logic to choose how to handle receiving a partial set of parameters. The default behavior is additive. That is, for any parameters not specified, the default value is to leave the corresponding properties alone. It does not try to revert unspecified parameters to default values.

So in your logic, you keep supplying different boolean parameters, leaving other ones unspecified. So you accumulate more of them with value true, and none of them get set back to false.

To avoid this, you could:

  • Supply values for all the parameters. For example, in your TestPage.razor:
<Direction @attributes="attributes" />
<button class="btn btn-primary" @…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by SteveSandersonMS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants