Skip to content

Keep a Back pressed while a page starts on its entry - #3633

Merged
pournasserian merged 2 commits into
mainfrom
3395-back-while-a-page-starts
Nov 24, 2026
Merged

pournasserian merged 2 commits into
mainfrom
3395-back-while-a-page-starts

Conversation

@pournasserian

Copy link
Copy Markdown
Member

Closes #3395

A Back pressed while the page before it was still starting could land on the wrong history entry. Two location-changing handlers were always registered: the shell's drawer handler, registered when the shell started (AdminLayout.razor), and the form's unsaved-changes guard, registered in OnInitialized (ContentForm.razor). While any such handler is registered, Blazor's popstate handler in blazor.webassembly.js does three things. It takes the Back back with history.go(+1), asks the .NET handlers, and then goes again with history.go(-1). Between those steps the current entry is the page being left, so a second Back pressed then moves from that entry. The test from #3394 hit exactly this.

Fix:

  • The drawer registers its handler only while it is open, and gives it up when it closes.
  • The form registers its guard at its first unsaved change, where its drafts start tracking it, and keeps it until the form is disposed. Once the form has a change, the guard asks as before.
  • NavigateAway sets the pass for the form's own move only while the guard is registered.
  • The specification's dirty guard (4.5) now says this.

What it leaves: Blazor still takes a Back back and goes again in some cases, so a quick second Back can still land wrong there:

  • a form that has had a change, also after a save, and after the same form loads another entry;
  • a page with the drawer open;
  • an open bulk progress dialog or secret dialog.

These go on the admin's follow-up list #3610.

Test: HistoryTests.TwoBacksFromAnEntryThatIsStillStartingLandTwoEntriesBack opens two lists and then an entry, and holds the entry's read by a Playwright route, so the entry page is still starting. It presses Back, and presses Back again from the page's popstate for that first Back. It expects the list two entries back, and checks that Forward goes to the list after it. On the code before the fix it failed three runs of three, staying one entry short.

Dependencies

None.

Acceptance

  • The cause is named, or the report is shown not to reproduce
  • An end-to-end case presses Back while a page starts and lands on the previous page

Verification

Run locally:

  • Build: dotnet build -c Release -warnaserror gave 0 warnings and 0 errors.
  • FluentCMS.Admin.Tests: 2144 of 2144 passed.
  • Architecture tests: 43 of 43 passed.
  • New end-to-end case: passed with FLUENTCMS_E2E_SLOW=1 and without it.
  • Related end-to-end classes: FormBehaviourTests, ListTests and FilterTests passed, 8 of 8.
  • Size check: eng/check-admin-size.cs, run once on a publish into an empty folder, gave 3,593,986 B of 3,600,000 B.
  • Markdown: markdownlint passed on the specification.

Only CI shows the rest of the end-to-end suite, the other test projects and providers, and the size check of the first download on its own publish.

@pournasserian pournasserian added type:bug Defect area:admin The Blazor WebAssembly admin and the admin halves of plugins labels Nov 24, 2026
@pournasserian
pournasserian merged commit 3ba8a82 into main Nov 24, 2026
24 checks passed
@pournasserian
pournasserian deleted the 3395-back-while-a-page-starts branch November 24, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:admin The Blazor WebAssembly admin and the admin halves of plugins type:bug Defect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Back pressed while a page starts can land on the wrong history entry

1 participant