Skip to content

[all components] Fix preventBaseUIHandler runtime wrapping - #4330

Merged
atomiks merged 11 commits into
mui:masterfrom
atomiks:codex/issue-4088-prevent-base-ui-handler
Mar 20, 2026
Merged

atomiks merged 11 commits into
mui:masterfrom
atomiks:codex/issue-4088-prevent-base-ui-handler

Conversation

@atomiks

@atomiks atomiks commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #4088

Summary

Make preventBaseUIHandler() available at runtime for synthetic event handlers that flow through Base UI props, including lone handlers and single-prop useRenderElement() paths.

Changes

  • Wrap lone synthetic event handlers in mergeProps() so typed handlers receive preventBaseUIHandler() at runtime.
  • Normalize single object props in useRenderElement() so direct BaseUIComponentProps event handlers get the same runtime behavior.
  • Add regressions for mergeProps, useRenderElement, Menu.Item, and Accordion.Trigger.

@atomiks atomiks added type: bug It doesn't behave as expected. typescript scope: all components Widespread work has an impact on almost all components. labels Mar 13, 2026
@atomiks

atomiks commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Codex Review

Overview

This patch makes preventBaseUIHandler() consistently available at runtime across Base UI's shared prop-merge paths, including direct useRenderElement() props and first-position object inputs in mergeProps() / mergePropsN(). The current branch keeps that fix centralized in the shared merge logic, and the latest cleanup removes now-redundant workaround handlers that were only needed before the runtime fix existed.

Findings

No blocking issues found in this patch.

1. ℹ️ [Informational] Browser perf checks remain effectively flat overall, with only small route-level variance in focused opener tests

Impact: The change sits in shared event and render-prop plumbing, so even small regressions would fan out across many components. The main risk area is open and mount work in controls that rely heavily on shared trigger/merge paths.

Evidence: I compared the current PR head against the latest master tip in Chromium using static exports, fresh browser instances, alternating run order, and aggregated repeated runs. The existing high-volume docs stress routes remained in the same band as master, and a later select-perf rerun with 100 no-throttle samples came back effectively flat. Shorter throttled reruns showed some small variance, but the larger baseline rerun did not reproduce a meaningful regression.

Stress-route runs:

Route Ref Mean (ms) p50 (ms) p95 (ms) Std dev (ms) Samples
/experiments/perf/non-popup-controls PR head 101.14 101.00 109.00 4.67 397
/experiments/perf/non-popup-controls master 101.49 101.20 110.50 5.29 392
/experiments/perf/contained-triggers PR head 102.44 100.70 121.90 11.32 389
/experiments/perf/contained-triggers master 103.87 104.90 125.60 12.34 389
/experiments/perf/detached-triggers PR head 43.20 42.50 50.50 3.48 387
/experiments/perf/detached-triggers master 42.58 41.30 51.00 4.46 395

Focused select opener reruns:

Scenario Ref Mean (ms) p50 (ms) p95 (ms) Std dev (ms) Samples
select-perf (100 samples, no slowdown) PR head 104.20 104.34 113.52 4.69 100
select-perf (100 samples, no slowdown) master 105.20 105.38 114.53 4.73 100
select-perf (30 samples, 4x slowdown) PR head 331.39 332.95 343.43 7.49 30
select-perf (30 samples, 4x slowdown) master 325.10 325.62 332.94 7.96 30

Recommendation: This still looks like the right tradeoff to land. If follow-up perf work is needed, prefer targeted hot-path simplifications inside the shared merge path over broader runtime machinery or component-by-component typing audits.

Confidence: 4/5

High confidence based on a full pass over the branch diff, focused regression coverage around the merge seed paths, fresh type/test verification, and repeated Chromium benchmarking against the latest master tip.

Notes

  • The branch has been rebased onto the latest master tip, and the review above reflects the rebased branch rather than the earlier pre-rebase snapshot.
  • The latest cleanups remove two redundant workarounds: the wrapEventHandler(ourHandler) fallback in the !theirHandler merge branch, and the empty onMouseDown shim in ComboboxChip that had only been forcing chip events through the older merge path.

@atomiks
atomiks force-pushed the codex/issue-4088-prevent-base-ui-handler branch from 6d57774 to 8281874 Compare March 13, 2026 08:32
@pkg-pr-new

pkg-pr-new Bot commented Mar 13, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@4330
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@4330
    

commit: 84e1ecb

@mui-bot

mui-bot commented Mar 13, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+255B(+0.06%) 🔺+97B(+0.07%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Mar 13, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 84e1ecb
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69bd1704f7d2770008b0308c
😎 Deploy Preview https://deploy-preview-4330--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks
atomiks force-pushed the codex/issue-4088-prevent-base-ui-handler branch from 1c78b6a to 2c486ca Compare March 13, 2026 09:53
@atomiks
atomiks marked this pull request as ready for review March 13, 2026 12:49
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Mar 18, 2026
@atomiks
atomiks force-pushed the codex/issue-4088-prevent-base-ui-handler branch from 2dbc511 to 011f6f7 Compare March 18, 2026 12:25
@github-actions github-actions Bot added PR: out-of-date The pull request has merge conflicts and can't be merged. and removed PR: out-of-date The pull request has merge conflicts and can't be merged. labels Mar 18, 2026
@atomiks
atomiks force-pushed the codex/issue-4088-prevent-base-ui-handler branch from 6b56659 to b1741d0 Compare March 19, 2026 05:31
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Mar 19, 2026
@atomiks
atomiks merged commit fb484d9 into mui:master Mar 20, 2026
7 checks passed
@atomiks
atomiks deleted the codex/issue-4088-prevent-base-ui-handler branch March 20, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: all components Widespread work has an impact on almost all components. type: bug It doesn't behave as expected. typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

event.preventBaseUIHandler is not a function

3 participants