Skip to content

fix: load browser helpers in embedded web components (#26043) (CP: 25.3) - #26057

Merged
vaadin-bot merged 1 commit into
25.3from
cherry-pick-26043-to-25.3-1790691257058
Sep 29, 2026
Merged

vaadin-bot merged 1 commit into
25.3from
cherry-pick-26043-to-25.3-1790691257058

Conversation

@vaadin-bot

Copy link
Copy Markdown
Collaborator

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

Original PR description

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

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>
@github-actions

Copy link
Copy Markdown
Contributor

Embedded web-component bootstrap now loads the browser helpers through a shared module

flowchart 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
Loading

The figure shows the two client entry points and where the browser helpers get installed. Before, Flow.ts imported the helper modules and defined collectBrowserDetails inline, while TaskGenerateWebComponentBootstrap emitted only init(), so embedded components never loaded the helpers (per #26041, Element.sizeSignal() stayed 0x0 and ExtendedClientDetails.refresh() was incomplete). After, both Flow.ts and the generated bootstrap import the new shared BrowserHelpers.ts, which installs the helper modules and sets window.Vaadin.Flow.getBrowserDetailsParameters on import. The import BrowserHelpers.js line in the bootstrap is the new path, per the pull request description.

Diagram Bot draws the mechanism this pull request touches; it does not review the change. Verify it against the diff.

Generated by Diagram Bot for issue #26057 · ◷

@vaadin-bot

Copy link
Copy Markdown
Collaborator Author

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]

@vaadin-bot
vaadin-bot enabled auto-merge (squash) September 29, 2026 14:53
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 1 446 files  +4   1 531 suites  +5   1h 25m 34s ⏱️ - 6m 30s
11 857 tests +5  11 789 ✅ +5  68 💤 ±0  0 ❌ ±0 
12 215 runs  +7  12 147 ✅ +7  68 💤 ±0  0 ❌ ±0 

Results for commit 3d1bcd3. ± Comparison against base commit 91d7bb5.

@vaadin-bot
vaadin-bot merged commit c067620 into 25.3 Sep 29, 2026
42 checks passed
@vaadin-bot
vaadin-bot deleted the cherry-pick-26043-to-25.3-1790691257058 branch September 29, 2026 15:02
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