Open
Conversation
knoobie
reviewed
Feb 16, 2026
flow-server/src/main/java/com/vaadin/flow/component/geolocation/Geolocation.java
Outdated
Show resolved
Hide resolved
|
Provides access to the browser's Geolocation API with two usage modes: - get(): one-shot position request with success/error callbacks - track(): continuous tracking via a reactive Signal tied to a component's lifecycle, using a GeolocationState sealed type (Pending | GeolocationPosition | GeolocationError) that enables exhaustive pattern matching Includes records for coordinates, position, error, and options, a JS module that bridges navigator.geolocation to Vaadin's event system, and unit + integration tests.
platosha
requested changes
Mar 9, 2026
flow-server/src/main/resources/META-INF/frontend/geolocation.js
Outdated
Show resolved
Hide resolved
Convert the plain JS geolocation module to TypeScript with typed interfaces matching the Java records, and move it from flow-server to flow-client where other core client infrastructure lives. The module is loaded via flow-client's index.ts entry point instead of a @jsmodule annotation, following the same pattern as Flow.ts.
Signal.get() requires a reactive context, which unit tests don't have. Use peek() to read signal values without dependency tracking, matching the pattern used by other signal tests in the codebase.
Import Geolocation from Flow.ts instead of index.ts, since Flow.ts is what Vite actually bundles at runtime. Add empty export to make TypeScript emit it as an ES module. Fix track IT test race condition by listening for the DOM event directly instead of polling the signal after a single JS round-trip. Use peek() in view code since it runs outside a reactive context. Add debug div to GeolocationView to report geolocation API status.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Wraps the browser's Geolocation API with two entry points:
Geolocation.get()for one-shot positionGeolocation.track()for continuous tracking via Signals, automatically tied to the owner component's lifecycle