Skip to content

feat(primitive): split composeEventHandlers into composeEvent and composePreventableEvent#3861

Open
langningchen-openclaw wants to merge 2 commits intoradix-ui:mainfrom
langningchen-openclaw:fix/compose-event-handlers
Open

feat(primitive): split composeEventHandlers into composeEvent and composePreventableEvent#3861
langningchen-openclaw wants to merge 2 commits intoradix-ui:mainfrom
langningchen-openclaw:fix/compose-event-handlers

Conversation

@langningchen-openclaw
Copy link
Copy Markdown

Description

Fix for issue #905 - The checkForDefaultPrevented API makes event composition difficult to follow.

Solution

Split composeEventHandlers into two clear utilities:

  • composeEvent: Always calls both handlers (no default prevented check)
  • composePreventableEvent: Only calls our handler if the original handler didn't call preventDefault()
  • composeEventHandlers: Marked as deprecated, kept for backward compatibility

Migration Guide

Instead of:
js composeEventHandlers(original, our, { checkForDefaultPrevented: false })

Use:
js composeEvent(original, our)

Instead of:
js composeEventHandlers(original, our, { checkForDefaultPrevented: true }) // default

Use:
js composePreventableEvent(original, our)

This makes the API more explicit and easier to understand at a glance.

Fixes #905

Related issue: #905

…posePreventableEvent

Fix for issue radix-ui#905 - The checkForDefaultPrevented API makes event composition
difficult to follow. This change splits it into two clear utilities:

- composeEvent: Always calls both handlers (no default prevented check)
- composePreventableEvent: Only calls our handler if default wasn't prevented
- composeEventHandlers: Deprecated, kept for backward compatibility

This makes the API more explicit and easier to understand at a glance.

Fixes: radix-ui#905
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 18, 2026

🦋 Changeset detected

Latest commit: 8219dc5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
@radix-ui/primitive Patch
@radix-ui/react-accordion Patch
@radix-ui/react-alert-dialog Patch
@radix-ui/react-checkbox Patch
@radix-ui/react-collapsible Patch
@radix-ui/react-context-menu Patch
@radix-ui/react-dialog Patch
@radix-ui/react-dismissable-layer Patch
@radix-ui/react-dropdown-menu Patch
@radix-ui/react-form Patch
@radix-ui/react-hover-card Patch
@radix-ui/react-menu Patch
@radix-ui/react-menubar Patch
@radix-ui/react-navigation-menu Patch
@radix-ui/react-one-time-password-field Patch
@radix-ui/react-password-toggle-field Patch
@radix-ui/react-popover Patch
@radix-ui/react-radio-group Patch
radix-ui Patch
@radix-ui/react-roving-focus Patch
@radix-ui/react-scroll-area Patch
@radix-ui/react-select Patch
@radix-ui/react-slider Patch
@radix-ui/react-switch Patch
@radix-ui/react-tabs Patch
@radix-ui/react-toast Patch
@radix-ui/react-toggle-group Patch
@radix-ui/react-toggle Patch
@radix-ui/react-toolbar Patch
@radix-ui/react-tooltip Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

[core/primitive][composeEventHandlers] Replace checkForDefaultPrevented api

1 participant