Skip to content

fix: accept any component in click-gesture onClick methods - #26650

Merged
mshabarov merged 1 commit into
mainfrom
fix/click-actions-accept-any-component
Oct 23, 2026
Merged

mshabarov merged 1 commit into
mainfrom
fix/click-actions-accept-any-component

Conversation

@totally-not-ai

@totally-not-ai totally-not-ai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review risk: two-way door — widens the parameter type of seven static onClick methods; binary and source compatible for existing callers.

missing API · flow-server · apps that want a clipboard, share, fullscreen, download or new-tab action on a component that is not a ClickNotifier, such as a context menu item

The click-gesture helpers (clipboard write, web share, fullscreen, download, open in new tab) required the clicked component to implement ClickNotifier, but they only listen for the browser click event on the component's root element and never use that interface. Components that are clickable in the browser but do not implement it, such as GridMenuItem, could only be used through an unchecked cast. The helpers now accept any Component.

Risks:

  • ⚠️ Public API: parameter widened from <T extends Component & ClickNotifier<?>> T to Component on Clipboard, WebShare, Fullscreen, Download and OpenInNewTab onClick methods. The erased signature was already onClick(Component, ...), so compiled code keeps linking, and existing call sites (including explicit type arguments) still compile.

  • ✅ No behaviour, security, memory, serialization, threading or performance impact.

  • Changed Clipboard.onClick, WebShare.onClick, Fullscreen.onClick, Download.onClick (3 overloads) and OpenInNewTab.onClick (2 overloads) to take a Component, and removed the ClickNotifier type parameter from their Javadoc.

  • Changed the test fixtures of these classes to use a plain component instead of a ClickNotifier, so the existing tests cover the wider type.

Working on behalf of Artur

The click-gesture APIs only attach a DOM click listener to the
component's root element and never use ClickNotifier, so requiring it
blocked components such as menu items that are clickable in the browser
but do not implement the interface. The erased signatures stay
onClick(Component, ...), so the change is binary compatible.
@totally-not-ai

Copy link
Copy Markdown
Contributor Author

Type of change

  • Bugfix
API changes

5 classes affected, 7 methods changed (parameter type widened, erasure unchanged)

// com.vaadin.flow.component.clipboard.Clipboard
- public static <T extends Component & ClickNotifier<?>> ClipboardBinding onClick(T component)
+ public static ClipboardBinding onClick(Component component)

// com.vaadin.flow.component.webshare.WebShare
- public static <T extends Component & ClickNotifier<?>> WebShareBinding onClick(T component)
+ public static WebShareBinding onClick(Component component)

// com.vaadin.flow.component.fullscreen.Fullscreen
- public static <T extends Component & ClickNotifier<?>> FullscreenBinding onClick(T component)
+ public static FullscreenBinding onClick(Component component)

// com.vaadin.flow.component.download.Download
- public static <T extends Component & ClickNotifier<?>> Registration onClick(T component, DownloadHandler handler)
+ public static Registration onClick(Component component, DownloadHandler handler)
- public static <T extends Component & ClickNotifier<?>> Registration onClick(T component, String url)
+ public static Registration onClick(Component component, String url)
- public static <T extends Component & ClickNotifier<?>> Registration onClick(T component, String url, String fileName)
+ public static Registration onClick(Component component, String url, String fileName)

// com.vaadin.flow.component.newtab.OpenInNewTab
- public static <T extends Component & ClickNotifier<?>> Registration onClick(T component, DownloadHandler handler)
+ public static Registration onClick(Component component, DownloadHandler handler)
- public static <T extends Component & ClickNotifier<?>> Registration onClick(T component, String url)
+ public static Registration onClick(Component component, String url)

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 1 668 files  ±0   1 754 suites  ±0   2h 5m 49s ⏱️ + 3m 53s
13 022 tests ±0  12 953 ✅ ±0  69 💤 ±0  0 ❌ ±0 
13 656 runs  ±0  13 587 ✅ ±0  69 💤 ±0  0 ❌ ±0 

Results for commit dc3310d. ± Comparison against base commit de3a9fc.

@Artur-
Artur- marked this pull request as ready for review October 23, 2026 11:43

@vaadin-review-bot vaadin-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

✅ Nothing to flag — the changes look good.

@mshabarov
mshabarov added this pull request to the merge queue Oct 23, 2026
Merged via the queue into main with commit e178a76 Oct 23, 2026
68 checks passed
@mshabarov
mshabarov deleted the fix/click-actions-accept-any-component branch October 23, 2026 14:05
vaadin-bot added a commit to vaadin/docs that referenced this pull request Oct 23, 2026
Clipboard.onClick() and WebShare.onClick() now accept any clickable
component, not only ones implementing ClickNotifier.

Documents vaadin/flow#26650 (`dc3310dd065caab3ab07b2e37e055a2600d4b32d`).
@github-actions

Copy link
Copy Markdown
Contributor

Pull request created: #6484

Generated by Documentation Bot · agent · 83 AIC · ⊞ 6.6K

@github-actions

Copy link
Copy Markdown
Contributor

Documentation Bot: Draft documentation pull request for this change: vaadin/docs#6484

Files updated:

  • articles/flow/browser-apis/clipboard-api.adoc
  • articles/flow/browser-apis/web-share-api.adoc

It was written from the state of this pull request as you see it now. Please review it and mark it ready for review.

Generated by Documentation Bot for #26650 · agent · 83 AIC · ⊞ 6.6K · ◷

Artur- pushed a commit to vaadin/docs that referenced this pull request Oct 23, 2026
)

Documentation for vaadin/flow#26650 by `@totally-not-ai`[bot].

> [!NOTE]
> The source pull request is merged, so this documentation describes the
final
> shape of the change. Please review it and mark it ready for review.

**Change categories:** API_CHANGE

| File | Change |
|------|--------|
| `articles/flow/browser-apis/clipboard-api.adoc` | "Other Click
Sources" no longer says `Clipboard.onClick()` requires `ClickNotifier`
-- it accepts any component |
| `articles/flow/browser-apis/web-share-api.adoc` | "Sharing on Click"
no longer says the trigger must implement `ClickNotifier` -- any
component whose root element receives the click works, including menu
items |

Auto-generated by the Documentation Bot — review before merging.

> Generated by [Documentation
Bot](https://github.com/vaadin/flow/actions/runs/39966647336) for #26650
· agent · 83 AIC · ⊞ 6.6K ·
[◷](https://github.com/search?q=repo%3Avaadin%2Fdocs+%22gh-aw-workflow-id%3A+doc-bot%22&type=pullrequests)
> - [x] expires <!-- gh-aw-expires: 2026-11-22T14:12:01.563Z --> on Nov
22, 2026, 2:12 PM UTC

<!-- gh-aw-agentic-workflow: Documentation Bot, engine: claude, model:
agent, id: 39966647336, workflow_id: doc-bot, run:
https://github.com/vaadin/flow/actions/runs/39966647336 -->

<!-- gh-aw-expires-type: pull-request -->

<!-- gh-aw-workflow-id: doc-bot -->
<!-- gh-aw-workflow-call-id: vaadin/flow/doc-bot -->
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