Skip to content

ui-core-components: Button silently drops a bare onFocus prop #30811

Closed

Description

@chirag-madlani

Passing onFocus to core Button has no effect — the handler never fires. Confirmed empirically during the antd Button migration (#30809).

Core Button is built on react-aria, which routes focus through its own useFocusable/focusProps rather than spreading a bare onFocus onto the DOM node, so the prop is accepted by the type (via ButtonHTMLAttributes) but silently discarded at runtime — the worst combination: it typechecks and does nothing.

Broke MetaPilot focus tracking in 4 files during the migration; worked around there with a wrapping <span onFocus>, which is a smell that belongs in the component instead.

Suggested fix: wire onFocus/onBlur through react-aria's focus props (or document them as unsupported and fail the type). Same shape of issue as #30803 — a react-aria behavior that silently diverges from the plain-DOM expectation consumers carry over from antd.

Status (2026-10-16)

Not reproducible on main. Core Button (components/base/buttons/button.tsx) passes the remaining props, including onFocus/onBlur, to react-aria's Button/Link, which support them. That spread has not changed since the library landed (#26035), and react-aria-components has been on ^1.16.0 since March, so there is no PR that "fixed" it. The original report most likely came from a different cause (Collate MetaPilot code or a test mock). No <span onFocus> workaround exists in OSS.

Verified with vitest: onFocus/onBlur fire on keyboard focus in/out, and onFocus fires on the link variant. Both cases fail when button.tsx is changed to drop the handlers.

Regression tests land in #35509 (button.test.tsx), which closes this issue.

Activity

  1. added this to Shipping and removed this from Roadmapon Oct 15, 2026
  2. moved this to Release Backlog 🚧 in Shippingon Oct 15, 2026
  3. moved this from Release Backlog 🚧 to In Review / QA 👀 in Shippingon Oct 16, 2026
  4. moved this from In Review / QA 👀 to Done ✅ in Shippingon Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

  • Status
    Done ✅
  • Status
    Done ✅

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions