alsoscotland / react-super-select

MIT License
95 stars 33 forks source link

Data elements having IDs that parse to Numbers causes error #151

Closed dave-irvine closed 6 years ago

dave-irvine commented 6 years ago

Example: https://codesandbox.io/s/mq4ry6m969

Open the dropdown menu and press spacebar.

Essentially the problem boils down to https://github.com/alsoscotland/react-super-select/blob/master/src/react-super-select.js#L896 which converts from strings to Number. Unfortunately when this Number later gets consumed in https://github.com/alsoscotland/react-super-select/blob/master/src/react-super-select.js#L557 it is part of a type-sensitive comparison and therefore fails to pass the test.

alsoscotland commented 6 years ago

@dave-irvine Thanks for submitting the issue. Will take a look soon

jayjaybeeuk commented 6 years ago

Hi there

We faced the same issue when data values were integers. The issue seems to be ficed for us by modifying the like that reads:

Return this._getTypeSafeOptionValue(optionValue)

To:

Return this._getTypeSafeOptionValue(optionValue).toString()

I can raise a pull request if you wish?

alsoscotland commented 6 years ago

@jayjaybeeuk thanks. This is on my todo list but it may be a couple days. If you want to make a PR that would be great too

alsoscotland commented 6 years ago

@dave-irvine @jayjaybeeuk https://github.com/alsoscotland/react-super-select/tree/v1.0.16 should hopefully fix this for you. Sorry it took a little longer than my usual response. I have been pretty slammed.