Skip to content

feat: add RouterState.isNavigationPending() to detect pre-navigation state#24617

Open
mvanhorn wants to merge 1 commit into
vaadin:mainfrom
mvanhorn:fix/24471-2026-06-12-1291-feat-routerstate-isnavigationpending
Open

feat: add RouterState.isNavigationPending() to detect pre-navigation state#24617
mvanhorn wants to merge 1 commit into
vaadin:mainfrom
mvanhorn:fix/24471-2026-06-12-1291-feat-routerstate-isnavigationpending

Conversation

@mvanhorn

Copy link
Copy Markdown

Summary

RouterState gains isNavigationPending(), returning true while navigationTarget is still null (before the first navigation completes), so user code can detect the pre-navigation state without an NPE.

Why this matters

In #24471, dereferencing RouterState.navigationTarget() in browserless tests, or in a running app before the first navigation, throws an NPE. @mcollovati noted the Javadoc already documents the null window, making the NPE an application bug, and proposed exactly this helper so the state is easy to detect. The navigationTarget component Javadoc now references the safe check, so users discover it where they would otherwise hit the null.

Testing

RouterStateTest covers both states: pending (null target, isNavigationPending() true, currentView() empty) and completed (target set, pending false).

Fixes #24471

@cla-assistant

cla-assistant Bot commented Jun 12, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@cla-assistant

cla-assistant Bot commented Jun 12, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@mcollovati mcollovati added the Contribution PRs coming from the community or external to the team label Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Contribution PRs coming from the community or external to the team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI routerState's navigationTarget leads to NPE in browserless tests

2 participants