Skip to content

fix: register UI event listeners through UIInitListener - #530

Merged
mcollovati merged 1 commit into
mainfrom
fix/ui-listeners-setup
Sep 1, 2026
Merged

mcollovati merged 1 commit into
mainfrom
fix/ui-listeners-setup

Conversation

@mcollovati

Copy link
Copy Markdown
Contributor

Flow 25.3 (vaadin/flow#25268) moved the service listeners onto the new VaadinServiceEventBus. BootstrapHandler now fires a UIInitEvent through the bus instead of calling VaadinService.fireUIInitListeners, which is deprecated for removal and no longer invoked by Flow.

The extension attached its CDI event forwarding listeners to the UI from an override of that method, so they were never registered: no navigation, poll or UI detach event reached CDI observers, and @RouteScoped beans got no context because RouteScopedContext observes BeforeEnterEvent and AfterNavigationEvent.

UIEventListener now implements UIInitListener and attaches itself to the UI before firing the CDI UIInitEvent, and is registered with addUIInitListener instead of a lambda. Only APIs available since Flow 1.0 are used, so the fix works on both Flow 25.2 and 25.3.

The unit tests fire the event the way Flow does, through the service event bus, reached reflectively so that they still compile and exercise the same code path against Flow 25.2, where the bus does not exist yet.

Flow 25.3 (vaadin/flow#25268) moved the service listeners onto the new
VaadinServiceEventBus. BootstrapHandler now fires a UIInitEvent through
the bus instead of calling VaadinService.fireUIInitListeners, which is
deprecated for removal and no longer invoked by Flow.

The extension attached its CDI event forwarding listeners to the UI from
an override of that method, so they were never registered: no navigation,
poll or UI detach event reached CDI observers, and @RouteScoped beans got
no context because RouteScopedContext observes BeforeEnterEvent and
AfterNavigationEvent.

UIEventListener now implements UIInitListener and attaches itself to the
UI before firing the CDI UIInitEvent, and is registered with
addUIInitListener instead of a lambda. Only APIs available since Flow 1.0
are used, so the fix works on both Flow 25.2 and 25.3.

The unit tests fire the event the way Flow does, through the service
event bus, reached reflectively so that they still compile and exercise
the same code path against Flow 25.2, where the bus does not exist yet.
@github-actions

Copy link
Copy Markdown

Test Results

144 tests  +1   144 ✅ +1   2m 32s ⏱️ +3s
 35 suites ±0     0 💤 ±0 
 35 files   ±0     0 ❌ ±0 

Results for commit aec1a95. ± Comparison against base commit 13cb33b.

This pull request removes 2 and adds 3 tests. Note that renamed tests count towards both.
com.vaadin.cdi.CdiVaadinServletServiceTest ‑ fireUIInitListeners_serialization_UIserializableAndListenersWork
com.vaadin.cdi.CdiVaadinServletServiceTest ‑ fireUIInitListeners_uiAttachedAndDetached_UIeventsCanBeObserved
com.vaadin.cdi.CdiVaadinServletServiceTest ‑ uiInit_serialization_UIserializableAndListenersWork
com.vaadin.cdi.CdiVaadinServletServiceTest ‑ uiInit_uiAttachedAndDetached_UIeventsCanBeObserved
com.vaadin.cdi.CdiVaadinServletServiceTest ‑ uiInit_uiEventListenersAttachedBeforeCdiEventIsFired

@mcollovati
mcollovati requested a review from caalador September 1, 2026 05:19
@mcollovati
mcollovati merged commit fdb7764 into main Sep 1, 2026
10 checks passed
@mcollovati
mcollovati deleted the fix/ui-listeners-setup branch September 1, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants