Standard API for major event handlers in 2.0
See original GitHub issueWhile we’re writing components for 2.0, we should standardize the API got event handlers.
Currently with props all event handlers are native event handlers.
E.g: onChange
of a checkbox is the native onChange of input type=checkbox
This leads to some problems, mdc-web introduce some additional properties on top of native controls.
E.g. checkbox has a indeterminate
state, select has selectedIndex
etc.
Getting these values from native event handlers which just pass the Event
, is tricky and most times requires creating a ref.
In order to solve this we can send added details to major event handlers(not necessarily all) like onChange for checkbox, select, onClick for button etc.
Current TS definition:
onClick: (e:Event) => void;
Updated version:
onChange:(e:Event, object: {
MDComponent: MaterialComponent;
checked: boolean;
indeterminate: boolean;
}) => void
The additional object makes sure that it is not counter intuitive to users if 1.0
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
But that’s a good idea
Possible