Skip to content

fix(ui): clear loading state when Edit page gets null post result (#307)#309

Merged
mpaulosky merged 4 commits into
devfrom
squad/307-fix-edit-null-post-redirect
May 11, 2026
Merged

fix(ui): clear loading state when Edit page gets null post result (#307)#309
mpaulosky merged 4 commits into
devfrom
squad/307-fix-edit-null-post-redirect

Conversation

@mpaulosky

Copy link
Copy Markdown
Owner

Summary

Closes #307

Working as Legolas (Frontend / UI / Blazor Specialist)

Problem

The Edit page used _model is null && _error is null as the "Loading..." condition. When a post is not found, OnParametersSetAsync calls NavigateTo("/blog") and returns early — never setting _model or _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.razor

  • Add private bool _isLoading = true; field
  • Replace derived condition _model is null && _error is null with _isLoading
  • Add role="status" ARIA attribute to the loading paragraph
  • Wrap OnParametersSetAsync body in try/finally { _isLoading = false; } — guarantees the spinner clears on every exit path including early return via NavigateTo

tests/Web.Tests.Bunit/Features/EditAclTests.cs

  • Update EditRedirectsToBlogWhenPostNotFound to capture cut and assert Loading... is not shown after null-post result

Validation

  • 89/89 bUnit tests pass (no regressions)
  • Pre-push gate passed (format check + release build)

Boromir and others added 2 commits May 11, 2026 13:58
…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>
Copilot AI review requested due to automatic review settings May 11, 2026 23:23
@github-actions github-actions Bot added the squad Squad triage inbox — Lead will assign to a member label May 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🏗️ PR Added to Squad Triage Queue

This PR has been labeled with squad and added to the triage queue.

Next steps:

  • The squad Lead will review and assign to an appropriate team member
  • A squad:member label will be added after triage

If you know which squad member should handle this, you can add the appropriate squad:member label yourself.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 _isLoading flag to drive the loading UI and ensured it is cleared via try/finally in OnParametersSetAsync.
  • Redirects to /blog when 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)
@github-actions

github-actions Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Test Results Summary

362 tests  +1   361 ✅ +1   19s ⏱️ -1s
  6 suites ±0     1 💤 ±0 
  6 files   ±0     0 ❌ ±0 

Results for commit dfe4e52. ± Comparison against base commit 9fcf7dc.

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented May 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.25000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.46%. Comparing base (9fcf7dc) to head (dfe4e52).

Files with missing lines Patch % Lines
src/Web/Features/BlogPosts/Edit/Edit.razor 81.25% 1 Missing and 2 partials ⚠️
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              
Files with missing lines Coverage Δ
src/Web/Features/BlogPosts/Edit/Edit.razor 85.00% <81.25%> (+4.44%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mpaulosky
mpaulosky merged commit 5e176dc into dev May 11, 2026
19 checks passed
@mpaulosky
mpaulosky deleted the squad/307-fix-edit-null-post-redirect branch May 11, 2026 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

squad Squad triage inbox — Lead will assign to a member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ui): redirect to /blog when post not found in Edit page (null-value stuck loading)

2 participants