material-components / material-components-web-react

Material Components for React (MDC React)
MIT License
2.02k stars 227 forks source link

singleSelection List doesn't remove selected class #905

Open rbare1 opened 5 years ago

rbare1 commented 5 years ago

In v0.13.0, the singleSelection list can't be used without the handleSelect prop. Previously, it would handle selected state properly on its own, but now it won't remove the selected class when selecting another option. Additionally, if you click around quickly, sometimes the previous list item will deselect.

This can be recreated with the screenshot tests by simply removing the handleSelect prop from the SelectionListTest.

v0.12.0: 2019-06-04_15-53-15

v0.13.0 2019-06-04_15-57-28

ghost commented 5 years ago

Can you show me your code with Stackblitz or Codepen? I tried to reproduce this issue in MacOS but failed.

rbare1 commented 5 years ago

https://stackblitz.com/edit/react-xz1pw3

ghost commented 5 years ago

https://github.com/material-components/material-components-web/blob/5e294f9f969d6fa3718ff2115e1a64bdba1cf241/packages/mdc-list/foundation.ts#L244-L257 Now handleClick doesn't check prop singleSelection.

@moog16 It seems this issue is from mdc-web. Can you move this issue there? And then I'll create a fixing PR!

moog16 commented 5 years ago

@TroyTae is it possible that we are just on an older version of mdc web? Has this already been fixed in 3.0?