fix(ui): clear loading state when Edit page gets null post result (#307)#309
Merged
Conversation
…t test - Edit.razor: null-value branch now navigates to /blog instead of leaving _model null (which caused infinite 'Loading...' state) - EditAclTests: added EditRedirectsToBlogWhenPostNotFound covering the Result.Ok(null) path Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add _isLoading flag (init true) replacing the _model is null && _error is null derived condition, so the spinner clears on every OnParametersSetAsync exit - Wrap OnParametersSetAsync body in try/finally to guarantee _isLoading = false even when NavigateTo+return early-exits (null post or unauthorized author paths) - Add role='status' ARIA attribute to the loading paragraph for accessibility - Update EditRedirectsToBlogWhenPostNotFound test to capture cut and assert Loading... is not shown after a null-post result Closes #307 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
🏗️ PR Added to Squad Triage QueueThis PR has been labeled with Next steps:
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes a Blazor UI edge case on the Blog Post Edit page where a null post result could leave the component stuck in a perpetual “Loading...” state (notably in bUnit where navigation may not unmount the component).
Changes:
- Introduced an explicit
_isLoadingflag to drive the loading UI and ensured it is cleared viatry/finallyinOnParametersSetAsync. - Redirects to
/blogwhen the queried post is not found (null value). - Updated bUnit coverage to assert that “Loading...” is not shown after the null-post redirect.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Web/Features/BlogPosts/Edit/Edit.razor | Reworks loading condition and ensures loading clears even on early navigation/return paths. |
| tests/Web.Tests.Bunit/Features/EditAclTests.cs | Adds/updates bUnit test to assert redirect + loading text is cleared for null post result. |
Comment on lines
67
to
+72
| protected override async Task OnParametersSetAsync() | ||
| { | ||
| var result = await Sender.Send(new GetBlogPostByIdQuery(Id)); | ||
| if (result.Success) | ||
| try | ||
| { | ||
| if (result.Value is not null) | ||
| var result = await Sender.Send(new GetBlogPostByIdQuery(Id)); | ||
| if (result.Success) |
Contributor
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #309 +/- ##
==========================================
+ Coverage 83.33% 83.46% +0.13%
==========================================
Files 47 47
Lines 1248 1252 +4
Branches 152 152
==========================================
+ Hits 1040 1045 +5
+ Misses 148 147 -1
Partials 60 60
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #307
Working as Legolas (Frontend / UI / Blazor Specialist)
Problem
The Edit page used
_model is null && _error is nullas the "Loading..." condition. When a post is not found,OnParametersSetAsynccallsNavigateTo("/blog")and returns early — never setting_modelor_error. The component stays on "Loading..." indefinitely (especially visible in bUnit where navigation doesn't unmount the component).Changes
src/Web/Features/BlogPosts/Edit/Edit.razorprivate bool _isLoading = true;field_model is null && _error is nullwith_isLoadingrole="status"ARIA attribute to the loading paragraphOnParametersSetAsyncbody intry/finally { _isLoading = false; }— guarantees the spinner clears on every exit path including earlyreturnviaNavigateTotests/Web.Tests.Bunit/Features/EditAclTests.csEditRedirectsToBlogWhenPostNotFoundto capturecutand assertLoading...is not shown after null-post resultValidation