Skip to content
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

[SupplyParameterFromQuery] property not being set during OnInitializedAsync #53055

Closed
1 task done
MohamedTwheed opened this issue Dec 29, 2023 · 14 comments
Closed
1 task done
Assignees
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. feature-model-binding
Projects
Milestone

Comments

@MohamedTwheed
Copy link

MohamedTwheed commented Dec 29, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

After migrating from .net7 to .net8 I encountered an issue that properties with [SupplyParameterFromQuery] not being set druing the OnInitializedAsync only after OnParametersSetAsync.

Ex of the bug:
Navigation with: https://localhost:44340/test?CrumbTrailItemId=662f20c8-b7c1-4145-a8cd-ad693913414a

    [SupplyParameterFromQuery]
    public string CrumbTrailItemId { get; set; }

    protected async Task OnInitializedAsync()
    {
        // this.CrumbTrailItemId  is null
    }

    protected async Task OnParametersSetAsync()
    {
        // this.CrumbTrailItemId  is "662f20c8-b7c1-4145-a8cd-ad693913414a"
    }

Expected Behavior

The property with annotation SupplyParameterFromQuery should be set at the beginning of the life cycle of the component but somehow its being set after OnParametersSetAsync.

Ex of expected behavior:
Navigation with: https://localhost:44340/test?CrumbTrailItemId=662f20c8-b7c1-4145-a8cd-ad693913414a

    [SupplyParameterFromQuery]
    public string CrumbTrailItemId { get; set; }

    protected async Task OnInitializedAsync()
    {
        // this.CrumbTrailItemId  is "662f20c8-b7c1-4145-a8cd-ad693913414a"
    }

Steps To Reproduce

Exceptions (if any)

.NET Version

8.0.0

Anything else?

none

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Dec 29, 2023
@symbiotic
Copy link

symbiotic commented Jan 8, 2024

i'm using noticing similar issues after moving from .NET 7 to .NET 8. with the parameter not always set, but also OnInitializedAsync not always firing. i'm using the components as a page though (with the page directive @page). i'll have to find time to create a separate issue, because this is a huge problem for me

@hakenr
Copy link
Contributor

hakenr commented Jan 10, 2024

related #51398

@MackinnonBuck
Copy link
Member

Tried this myself and in my basic test app, I was able to access updated values of [SupplyParameterFromQuery] properties in OnInitializedAsync(). This was true both when refreshing the page and navigating from another page.

Could you provide a repro project so we can investigate the issue further?

@MackinnonBuck MackinnonBuck added the Needs: Repro Indicates that the team needs a repro project to continue the investigation on this issue label Jan 13, 2024
@ghost
Copy link

ghost commented Jan 13, 2024

Thank you for filing this issue. In order for us to investigate this issue, please provide a minimal repro project that illustrates the problem without unnecessary code. Please share with us in a public GitHub repo because we cannot open ZIP attachments, and don't include any confidential content.

@ghost ghost added Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. Status: No Recent Activity labels Jan 13, 2024
@ghost
Copy link

ghost commented Jan 17, 2024

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

See our Issue Management Policies for more information.

@rabberbock
Copy link

rabberbock commented Jan 18, 2024

@MackinnonBuck Here is a repro. https://github.com/rabberbock/SupplyQueryBugNet8/tree/main/BlazorApp

The issue surfaces when the page you are navigating from has SupplyParameterFromQuery and the page you are going to has one as well.

https://github.com/rabberbock/SupplyQueryBugNet8/blob/main/BlazorApp/Pages/Counter.razor#L16
https://github.com/rabberbock/SupplyQueryBugNet8/blob/main/BlazorApp/Pages/Home.razor#L22

Screenshare.-.2024-01-18.5_06_29.PM.mp4

Thank you for all the hard work the Blazor team puts in!

@kyletinsley
Copy link

kyletinsley commented Jan 19, 2024

I can confirm this issue is still occurring in 8.0.1.
Related: #51398

@milkyjoe90
Copy link

I'm also experiencing this issue in 8.0 and 8.0.1, have reverted back to 7 in order to continue developing.

@ghost ghost closed this as completed Jan 24, 2024
@MohamedTwheed
Copy link
Author

This issue still exist and as a workaround i've to manually parse out the parameters inside OnInitialized for the first run.
any stable solution?

@rabberbock
Copy link

@MackinnonBuck Can we please get this issue reopened? I put up a repro above. Thanks!

@kyletinsley
Copy link

Why is this closed? This change breaks our app and we cannot upgrade to 8.0.1.

@MackinnonBuck MackinnonBuck reopened this Jan 25, 2024
@MackinnonBuck MackinnonBuck added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. Needs: Repro Indicates that the team needs a repro project to continue the investigation on this issue labels Jan 25, 2024
@MackinnonBuck MackinnonBuck self-assigned this Jan 25, 2024
@MackinnonBuck MackinnonBuck added investigate bug This issue describes a behavior which is not expected - a bug. and removed investigate Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Jan 25, 2024
@mkArtakMSFT mkArtakMSFT added this to the 8.0.x milestone Jan 26, 2024
@mkArtakMSFT
Copy link
Member

Thanks for raising this issue, everyone. Looks like we had left a gap in the original PR. We're going to address it in the next servicing release (probably 8.0.3). I will update the milestone to the target release, as soon as we get the servicing PR merged.

@mkArtakMSFT mkArtakMSFT added this to 8.0.x in Servicing Jan 26, 2024
@mkArtakMSFT mkArtakMSFT moved this from 8.0.x to In Progress in Servicing Jan 26, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@mikecasas
Copy link

Any update on this being assigned a milestone for release.

@hakenr
Copy link
Contributor

hakenr commented Feb 26, 2024

The PR #53625 is associated to 8.0.3 milestone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. feature-model-binding
Projects
Development

No branches or pull requests

10 participants