Repository navigation
fix: load browser helpers in embedded web components (#26043) (CP: 25.3) - #26057
Conversation
Fixes #26041 ## Summary Exported web components did not load the browser helpers that some server-side APIs need. Because of this, `Element.sizeSignal()` stayed at 0x0 with a TypeError on embedding pages, and `ExtendedClientDetails.refresh()` did not collect the full browser details. This PR puts all browser helpers in one shared module and loads it for both normal apps and embedded web components. ## What changed - **Behavior change (embedded web components only):** the generated web component bootstrap now also imports `BrowserHelpers.js`. The helpers (element resize, clipboard, download, geolocation, wake lock, web share, fullscreen, page visibility, screen orientation) now work on embedding pages. `window.Vaadin.Flow.getBrowserDetailsParameters` is now set there too. Regular Flow apps behave the same as before. - New `flow-client/.../BrowserHelpers.ts` imports all helper modules and exports `collectBrowserDetails()`. This code moved out of `Flow.ts` without changes. When the module is imported, it sets the function as `window.Vaadin.Flow.getBrowserDetailsParameters`. - `Flow.ts` now imports `BrowserHelpers.ts`. It no longer sets `getBrowserDetailsParameters` in its constructor. - `TaskGenerateWebComponentBootstrap` adds the import line after `init()`. - New embedding test assets (`ElementSizeComponent`/`Exporter`, `BrowserDetailsComponent`/`Exporter`) and their HTML pages. ## Test summary **Web component bootstrap generation:** - Generated bootstrap imports `BrowserHelpers.js` **Browser helpers (client):** - Installs `collectBrowserDetails` as `getBrowserDetailsParameters` - Collects screen, timezone and feature-state parameters as strings **Embedded web components:** - `sizeSignal()` reports the initial size and updates after a resize - `ExtendedClientDetails.refresh()` collects the full details, including web share support --------- Co-authored-by: totally-not-ai[bot] <290682512+totally-not-ai[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Artur Signell <artur@vaadin.com>
Embedded web-component bootstrap now loads the browser helpers through a shared moduleflowchart LR
subgraph Before
direction TB
BF["Flow.ts (imports helper modules, defines collectBrowserDetails)"]
BH["helper modules + getBrowserDetailsParameters"]
BW["web-component-bootstrap.js (init only)"]
BF -->|imports and installs| BH
BW -.->|helpers never loaded| BH
end
subgraph After
direction TB
AF["Flow.ts"]
AB["BrowserHelpers.ts (installs getBrowserDetailsParameters on import)"]:::changed
AW["web-component-bootstrap.js"]
AH["helper modules (ElementResize, Clipboard, ...)"]
AF -->|imports| AB
AW -->|import BrowserHelpers.js (new)| AB
AB -->|installs| AH
end
Before ~~~ After
classDef changed stroke:#c9a227,stroke-width:3px
The figure shows the two client entry points and where the browser helpers get installed. Before, Diagram Bot draws the mechanism this pull request touches; it does not review the change. Verify it against the diff.
|
|
This PR is eligible for auto-merging policy, so it has been approved automatically. If there are pending conditions, auto merge (with 'squash' method) has been enabled for this PR [Message is sent from bot] |
|



This PR cherry-picks changes from the original PR #26043 to branch 25.3.
Original PR description