Repository navigation
Conversation
|
Thanks for your PR, @Yuvan111. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
| } | ||
| } | ||
|
|
||
| var firstId = ids[0]; |
There was a problem hiding this comment.
Additional coverage gaps
toggles prevention off and immediately back on—it never clicks while prevention is false. The prevented-click assertions also check URL and callback count, but not history mutations when the URL remains unchanged.
|
|
||
| function onClickListenerRegistered(isDispatchingClick: boolean) { | ||
| // Removing a listener during dispatch skips it for that click. Let it run before reordering. | ||
| if (isDispatchingClick) { |
There was a problem hiding this comment.
Nested clicks can bypass enhanced navigation
If a synchronous interactive click re-registers a renderer’s click listener, then triggers another element’s .click(), the inner navigation listener clears the pending reorder. This removes the navigation listener from the outer event’s dispatch snapshot. The outer link then performs a full page load, losing enhanced-navigation behavior.
This reproduced 10/10 times in Chromium using the PR’s event-delegation and navigation-listener code. Controls without the nested click retained interception. Managed interop and enhanced-page fetching were stubbed, so this is DOM-level evidence, not full Blazor E2E verification.
Reordering should wait until no outer managed click remains active. Add a Selenium regression covering this sequence.
|
Closed, follow this PR: #70299 |
Fix @OnClick:preventDefault not being respected by Blazor enhanced navigation
Description
This PR fixes an issue where Blazor enhanced navigation can navigate or update browser history despite an interactive link specifying @OnClick:preventDefault.
The change ensures enhanced navigation processes clicks after interactive renderers have had an opportunity to cancel the default action. This allows prevented clicks to invoke their callbacks without navigating, while preserving enhanced navigation for ordinary links and static server-rendered pages.
Root cause
Enhanced navigation registers its document-level click listener before interactive renderers. It can therefore update browser history before Blazor processes @OnClick:preventDefault. Cancelling the browser’s default action afterward does not undo that navigation.
Solution
Before Fix
52514_BeforeFix.mp4
After Fix
52514_AfterFix.mp4
Test coverage
Fixes #52514