Skip to content

Conversation

@Artur-
Copy link
Member

@Artur- Artur- commented Jan 29, 2026

Add a signal that reflects the current locale and updates automatically when setLocale() is called. This allows components to reactively respond to locale changes using the signals API.

Add a read-only signal that reflects the current locale and updates
automatically when setLocale() is called. This allows components to
reactively respond to locale changes using the signals API.
@Artur- Artur- requested a review from tltv January 29, 2026 13:29
*/
private Locale locale = Locale.getDefault();

private transient ValueSignal<Locale> localeSignal;
Copy link
Member

Choose a reason for hiding this comment

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

This use case involves multiple UIs which according to our rules mean it should be a SharedValueSignal.

@@ -127,6 +129,8 @@ public class UI extends Component

private Locale locale = Locale.getDefault();
Copy link
Member

Choose a reason for hiding this comment

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

Could we remove this field and always store the value in a signal instead of having two sources of truth?

@github-actions
Copy link

github-actions bot commented Jan 29, 2026

Test Results

1 146 files   -   204  1 146 suites   - 204   1h 11m 4s ⏱️ - 6m 8s
7 327 tests  - 2 219  7 012 ✅  - 2 466  47 💤  - 21  9 ❌ +9  259 🔥 +259 
7 758 runs   - 2 259  7 435 ✅  - 2 506  55 💤  - 21  9 ❌ +9  259 🔥 +259 

For more details on these failures and errors, see this check.

Results for commit 980cb29. ± Comparison against base commit 32fc241.

This pull request removes 2231 and adds 12 tests. Note that renamed tests count towards both.
com.vaadin.base.devserver.AbstractDevServerRunnerTest ‑ shouldPassEncodedUrlToDevServer
com.vaadin.base.devserver.AbstractDevServerRunnerTest ‑ updateServerStartupEnvironment_preferIpv4_LocalhostIpAddressAddedToProcessEnvironment
com.vaadin.base.devserver.AbstractDevServerRunnerTest ‑ updateServerStartupEnvironment_preferIpv6_LocalhostIpAddressAddedToProcessEnvironment
com.vaadin.base.devserver.BrowserLiveReloadAccessorImplTest ‑ getLiveReload_devMode_contextHasNoReloadInstance_instanceIsCreated
com.vaadin.base.devserver.BrowserLiveReloadAccessorImplTest ‑ getLiveReload_devMode_contextHasReloadInstance_instanceIsReturned
com.vaadin.base.devserver.BrowserLiveReloadAccessorImplTest ‑ getLiveReload_liveReloadDisabled_instanceIsCreated
com.vaadin.base.devserver.BrowserLiveReloadAccessorImplTest ‑ getLiveReload_productionMode_nullIsReturned
com.vaadin.base.devserver.DebugWindowConnectionLicenseCheckTest ‑ checkLicense_invalidLicense_sendLicenseCheckFailed
com.vaadin.base.devserver.DebugWindowConnectionLicenseCheckTest ‑ checkLicense_noLicenseKeys_sendLicenseCheckFailed
com.vaadin.base.devserver.DebugWindowConnectionLicenseCheckTest ‑ checkLicense_validLicense_sendLicenseOk
…
com.vaadin.flow.component.UILocaleSignalTest ‑ localeSignal_initialValue_matchesGetLocale
com.vaadin.flow.component.UILocaleSignalTest ‑ localeSignal_multipleLocaleChanges_signalFollows
com.vaadin.flow.component.UILocaleSignalTest ‑ localeSignal_multipleSignalWrites_getLocaleFollows
com.vaadin.flow.component.UILocaleSignalTest ‑ localeSignal_sameInstance_returnedOnMultipleCalls
com.vaadin.flow.component.UILocaleSignalTest ‑ localeSignal_setLocale_signalUpdated
com.vaadin.flow.component.UILocaleSignalTest ‑ localeSignal_writeToSignal_updatesGetLocale
com.vaadin.flow.server.VaadinSessionLocaleSignalTest ‑ localeSignal_initialValue_matchesGetLocale
com.vaadin.flow.server.VaadinSessionLocaleSignalTest ‑ localeSignal_multipleLocaleChanges_signalFollows
com.vaadin.flow.server.VaadinSessionLocaleSignalTest ‑ localeSignal_multipleSignalWrites_getLocaleFollows
com.vaadin.flow.server.VaadinSessionLocaleSignalTest ‑ localeSignal_sameInstance_returnedOnMultipleCalls
…

♻️ This comment has been updated with latest results.

@tltv tltv added the signals label Feb 2, 2026
- Change return type from Signal to WritableSignal for both UI and
  VaadinSession
- Use SharedValueSignal for VaadinSession (thread-safe for multiple UIs)
- Signal becomes source of truth once accessed via localeSignal()
- Add effect in UI to notify LocaleChangeObservers on signal changes
- Maintain backward compatibility when signals feature is not enabled
The signal now holds the locale value directly instead of mirroring a
separate field. For VaadinSession, the locale field is retained only
for serialization since SharedValueSignal is transient.
Document that writing directly to the signal does not trigger
LocaleChangeObservers (UI) or propagate to UIs (VaadinSession).
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 2, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants