-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
BugSomething is broken and not working as intended in the system.Something is broken and not working as intended in the system.untriaged
Description
Summary
The onClick prop typing for the Button component is missing the MouseEvent
Expected behavior
The onClick prop's type definition should include React.MouseEvent<HTMLButtonElement> as an argument to the callback function. This is standard and expected behavior for event handlers in React.
The expected type should be: onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;.
Actual behavior
Currently, the type definition for the onClick prop on the Button component does not provide the MouseEvent object to the handler function. The type is likely defined as onClick?: () => unknown;.
This prevents developers from accessing standard event properties and methods like event.preventDefault(), event.stopPropagation(), or `
`.
Steps to reproduce
- Instantiate a
Buttoncomponent in a TypeScript project. - Pass a handler function to the
onClickprop. - Attempt to access the
eventobject within the handler. - TypeScript will throw an error because the
eventparameter is not defined in the function's signature.
Are you using React components?
Yes
Polaris version number
^13.5.0
Browser
Chrome Version 139.0.7258.128
Device
Macbook Air M2
Metadata
Metadata
Assignees
Labels
BugSomething is broken and not working as intended in the system.Something is broken and not working as intended in the system.untriaged