Skip to content

feat: add UI router state signal#24234

Merged
Artur- merged 5 commits intomainfrom
feature/router-signal
May 6, 2026
Merged

feat: add UI router state signal#24234
Artur- merged 5 commits intomainfrom
feature/router-signal

Conversation

@Artur-
Copy link
Copy Markdown
Member

@Artur- Artur- commented May 1, 2026

Expose UI.routerStateSignal() as a read-only Signal holding the current Location, RouteParameters, active chain and navigation target class. The signal is updated atomically alongside AfterNavigationEvent dispatch, so reactive consumers and listeners observe the same state.

Lets components observe the active route via Signal.effect instead of registering an AfterNavigationListener and manually fetching the initial state from UIInternals on attach. Fine-grained projections (current location, route parameters, leaf view) are derivable with Signal.map; two-way URL/parameter binding is intentionally left for a follow-up so its API can be designed independently.

Artur- added 2 commits May 1, 2026 06:25
Expose UI.routerStateSignal() as a read-only Signal<RouterState>
holding the current Location, RouteParameters, active chain and
navigation target class. The signal is updated atomically alongside
AfterNavigationEvent dispatch, so reactive consumers and listeners
observe the same state.

Lets components observe the active route via Signal.effect instead of
registering an AfterNavigationListener and manually fetching the
initial state from UIInternals on attach. Fine-grained projections
(current location, route parameters, leaf view) are derivable with
Signal.map; two-way URL/parameter binding is intentionally left for a
follow-up so its API can be designed independently.
Shared RouterStateLayout subscribes to UI.routerStateSignal() and
renders the active path, navigation target class, route parameters
and an update counter. Two views (A and B/:id?) navigate between
each other and self-navigate with different route parameters.

The IT verifies the layout's display tracks each navigation, that
self-navigation with a new :id parameter still triggers an update,
and that an unrelated UI mutation (UI.setLocale) does NOT fire the
router signal.
@github-actions github-actions Bot added the +0.1.0 label May 1, 2026
The route value uses the FQN, so the rendered path is
"com.vaadin.flow.uitest.ui.routerstate.RouterStateBView/99". The
earlier waitForPath calls already use endsWith; the strict
assertEquals on the locale-step assertion didn't, causing the IT to
fail in CI. Switch it to endsWith for consistency.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2026

Test Results

 1 398 files  + 3   1 398 suites  +3   1h 16m 15s ⏱️ + 1m 2s
10 095 tests +11  10 025 ✅ +11  70 💤 ±0  0 ❌ ±0 
10 570 runs  +11  10 491 ✅ +11  79 💤 ±0  0 ❌ ±0 

Results for commit df3d68c. ± Comparison against base commit b9356e4.

♻️ This comment has been updated with latest results.

@mshabarov mshabarov requested a review from heruan May 4, 2026 11:43
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 4, 2026

Copy link
Copy Markdown
Member

@heruan heruan left a comment

Choose a reason for hiding this comment

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

Clean addition that mirrors the existing localeSignal() pattern. Test coverage is solid. LGTM

@Artur- Artur- added this pull request to the merge queue May 6, 2026
Merged via the queue into main with commit ae31992 May 6, 2026
69 of 71 checks passed
@Artur- Artur- deleted the feature/router-signal branch May 6, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants