Skip to content

feat(ui5-button): make click button preventable #11318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nnaydenow
Copy link
Contributor

@nnaydenow nnaydenow commented Apr 14, 2025

Currently, the click event on the ui5-button is the native click event from the user interaction. This creates some problems. One main issue is that the click event cannot be prevented because the event handler in the template is always attached first. This means that the isPrevented flag is missing if the event is prevented during the bubble phase.

A bigger problem happens when the ui5-button has type="Submit" and is inside a HTML form element. In this case, each time the button is clicked, the form is submitted, even if the click event is prevented.

This pull request fixes the issue by changing the click event to a CustomEvent, instead of the native Event. This change is a soft breaking change because, in most cases, only event.target or event.currentTarget are used, and no other event details are usually needed. To provide backward compatibility the new custom event includes the original native event inside its e.detail.nativeEvent, so users can still access the original event if needed.

Fixes: #11103
Fixes: #9830

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Button]: Submit button no longer appears as submitter of event [ui5-button]: wrong behavior in form
1 participant