Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Remove [de]registerEventHandler methods from adapters #2813

Closed
10 of 19 tasks
patrickrodee opened this issue May 24, 2018 · 6 comments
Closed
10 of 19 tasks

Remove [de]registerEventHandler methods from adapters #2813

patrickrodee opened this issue May 24, 2018 · 6 comments
Labels
backlog this-Q Unresolved (Archived) Open and unresolved issues and PRs that were closed due to archiving the repository.

Comments

@patrickrodee
Copy link
Contributor

patrickrodee commented May 24, 2018

Our adapters often have registerEventHandler/deregisterEventHandler methods that are used to add and remove event listeners from DOM nodes. Many frameworks (React, Angular, Vue, etc) prefer events to be bound directly on the DOM elements. This has the benefit of not requiring references to the DOM in the component lifecycle and ensuring that the event handlers are appropriately cleaned up on component destruction.

For many of those frameworks, the registerEventHandler/deregisterEventHandler adapter methods become no-ops.

We should remove the registerEventHandler/deregisterEventHandler methods from our adapters and instead expose information about which handlers should be bound to which events. Registering the event handlers will then become the responsibility of those who wrap our components.

Packages that may require updates, as of 5/29/18:

  • checkbox
  • chips
  • dialog
  • drawer
  • floating-label
  • form-field
  • grid-list
  • icon-button (which replaces icon-toggle)
  • line-ripple
  • menu
  • radio
  • ripple
  • select
  • slider
  • snackbar
  • top-app-bar (which replaces toolbar)
  • tab
  • tab-indicator
  • text-field and text-field icon
@kfranqueiro
Copy link
Contributor

You say "expose information" which I assume means documentation... but I assume we also need to move any existing registrations out of the foundation and into our vanilla components, right?

@patrickrodee
Copy link
Contributor Author

That's correct

@kfranqueiro
Copy link
Contributor

kfranqueiro commented May 29, 2018

Tracking this as one issue for now, but we will undoubtedly want to PR this one package at a time.

IIRC a couple of packages may also dynamically add and remove event handlers (e.g. menu I think?). I'm not sure if we can move registration out of the foundation in those cases?

@aluminick
Copy link

Hi, is adapter and foundation the same thing? And can you give me a sample code on integrating MDC with React using adapter/foundation?

@kfranqueiro
Copy link
Contributor

Foundation, adapter, and component are briefly described here: https://github.com/material-components/material-components-web/blob/master/docs/code/architecture.md#javascript

We have a codelab that walks through wrapping a component for React: https://codelabs.developers.google.com/codelabs/mdc-112-web/index.html

acdvorak added a commit that referenced this issue Dec 13, 2018
### Issues fixed

* Fixes #4005 (via new `mdc-snackbar-viewport-margin()` mixin)
* Fixes #3981
* Fixes #2916 (via new `MDCSnackbar:closing` and `MDCSnackbar:closed` events)
* Fixes #2628
* Fixes #1466 (via new `close()` method)
* Fixes #1398
* Fixes #1258
* Fixes #11 (the label now expands indefinitely to fit the text)
* Refs #2813

### Screenshots

![Baseline without action button](https://user-images.githubusercontent.com/409245/49956261-a080ca80-feb9-11e8-8287-b7e805344115.png)

![Baseline with action button](https://user-images.githubusercontent.com/409245/49956109-4a138c00-feb9-11e8-9213-3241fa86a1b8.png)

![Stacked layout](https://user-images.githubusercontent.com/409245/49956173-6a434b00-feb9-11e8-8a03-2e58ccc8f763.png)

BREAKING CHANGE: Snackbar's DOM and APIs have changed to match the latest design guidelines. See the Snackbar documentation for more information.
@abhiomkar abhiomkar added this-Q and removed backlog labels Apr 19, 2019
@moog16
Copy link
Contributor

moog16 commented May 8, 2019

@abhiomkar I'm going to fix this for top app bar to fix #4527.

@asyncLiz asyncLiz added the Unresolved (Archived) Open and unresolved issues and PRs that were closed due to archiving the repository. label Jan 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backlog this-Q Unresolved (Archived) Open and unresolved issues and PRs that were closed due to archiving the repository.
Projects
None yet
Development

No branches or pull requests

6 participants