question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Standard API for major event handlers in 2.0

See original GitHub issue

While 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:open
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
cromefirecommented, Mar 4, 2019

But that’s a good idea

0reactions
cromefirecommented, Jul 18, 2019

Possible

Read more comments on GitHub >

github_iconTop Results From Across the Web

[DEPRECATED] Outlook Calendar REST API reference ...
The Calendar API provides access to events, calendar, and calendar group data secured by Azure Active Directory on Office 365, and to similar ......
Read more >
Introduction to the Event Notification Model in CDI 2.0
Simply put, the CDI 2.0 event notification model is a classic implementation of the Observer pattern, based on the @Observes method-parameter ...
Read more >
Event reference - MDN Web Docs - Mozilla
This topic provides an index to the main sorts of events you might be interested in (animation, clipboard, workers etc.) along with the...
Read more >
Event Handling - CanJS
CanJS makes it easy to handle any any standard DOM event, such as a change event, in your component. To add an event...
Read more >
Events | Maps JavaScript API - Google Developers
Events · User Interface Events · Handling Events · Accessing Arguments in UI Events · Using Closures in Event Listeners · Getting and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found