material-components / material-components-web

Modular and customizable Material Design UI components for the web
https://material.io/develop/web
MIT License
17.14k stars 2.15k forks source link

Chips: Improve clarity of documentation regarding externally managing chip elements #2891

Open coleweinman opened 6 years ago

coleweinman commented 6 years ago

Bugs

The MDCChipSet.addChip() function is broken in 0.36.0.

0.36.0: https://codepen.io/coleweinman1/pen/YvGXZx 0.35.0: https://codepen.io/coleweinman1/pen/XYjbam

What MDC Web Version are you using?

0.36.0

What browser(s) is this bug affecting?

Chrome 67

What OS are you using?

Windows 10

What are the steps to reproduce the bug?

  1. Create a MDCChipSet
  2. Invoke the MDCChipSet.addChip() function

What is the expected behavior?

A chip to be added to the chip set

What is the actual behavior?

An error is given: Uncaught TypeError: Cannot read property 'querySelector' of undefined

Any other information you believe would be useful?

After reverting back to 0.35.0, this error doesn't occur.

kfranqueiro commented 6 years ago

The MDCChipSet#addChip API was modified in 0.36.0, as mentioned in the changelog. It now expects a chip DOM element to be passed, rather than constructing it itself based on a text string (although the error you received suggests you weren't passing anything). This was changed in #2791.

See https://github.com/material-components/material-components-web/tree/v0.36.0/packages/mdc-chips#mdcchipset for the updated documentation. The updated documentation for 0.36.0 has unfortunately not yet been reflected on material.io, as the site team is still working on streamlining the update process.

kfranqueiro commented 6 years ago

After discussing with the team, we think we can improve the clarity of the documentation a bit with regard to how these APIs expect the chip elements to be managed externally now, so I'll track this for that purpose.