Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to react-select v2 #58

Merged
merged 7 commits into from
Jul 3, 2018
Merged

Upgrade to react-select v2 #58

merged 7 commits into from
Jul 3, 2018

Conversation

furious-luke
Copy link
Contributor

Workforce is upgrading to react-select v2, and so we need to bump react-object-list too. I've used the same approach as for Workforce; create a thin wrapper that manages converting the API from v1 to v2 for us, so we don't have to change each usage of react-select.

I've noticed that a couple of strange warnings appear in the console as a result of prop types:

image

image

It looks like we're passing undefined to a prop type definition somewhere, but that seems pretty strange to me. Probably need someone more familiar with how this package works to take a look.

There were a lot of snapshot tests that needed updating, I went through them and couldn't spot anything wrong.

@codecov
Copy link

codecov bot commented Jun 7, 2018

Codecov Report

Merging #58 into master will decrease coverage by 0.86%.
The diff coverage is 87.8%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #58      +/-   ##
==========================================
- Coverage     100%   99.13%   -0.87%     
==========================================
  Files          59       60       +1     
  Lines         542      581      +39     
  Branches      118      128      +10     
==========================================
+ Hits          542      576      +34     
- Misses          0        5       +5
Impacted Files Coverage Δ
src/filters/types/Date.js 100% <ø> (ø) ⬆️
src/filters/types/Choice.js 100% <ø> (ø) ⬆️
src/filters/utils/FilterComparison.js 100% <100%> (ø) ⬆️
src/actions-filters/SelectFilters.js 100% <100%> (ø) ⬆️
src/utils/Select.js 86.48% <86.48%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d58b3fe...b5f7783. Read the comment docs.

@furious-luke furious-luke requested review from scaredcat and tabby-or-not and removed request for scaredcat June 12, 2018 23:33
value={44}
valueKey="value"
/>
<div
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we'd like to keep this mocked to <Select.Async>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. Can create a mock for the new Select.js component as well to cover this case, similar to:
https://github.com/uptick/react-object-list/blob/master/__mocks__/react-select.js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As recommended by @scaredcat I've updated the react-select mock to provide a better name for Select.Async.

}
}

return nextProps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I try

const props = {
   value: 101010
}
const transform = {
  value: ['value', val => parseInt(val.toString(), '2')]
}

convertProps(props, transforms) // {val: 101010}

since KNOWN_PROPS overwrites the transform of 'value' back to the original value.

this function would only work if a value transform does not save it back to the original prop key

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's the intended behavior. Anything that needs a transform would be removed from KNOWN_PROPS; it's just a way of avoiding errors being thrown out for props that don't need a transform.

value={44}
valueKey="value"
/>
<div
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. Can create a mock for the new Select.js component as well to cover this case, similar to:
https://github.com/uptick/react-object-list/blob/master/__mocks__/react-select.js

Copy link
Contributor

@scaredcat scaredcat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

react-select 2 has significant UI changes as well, impacting the APILists on workforce. Do we need get UX team approval?

@@ -1,6 +1,6 @@
import React from 'react'
import PropTypes from 'prop-types'
import Select from 'react-select'
import Select from '../../utils/Select'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is used below to determine propTypes. Happy to simply change the proptype check to a catch all propTypes.object and removing this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scaredcat This should be working now; I've added react-select prop types into the wrapper.

@furious-luke
Copy link
Contributor Author

I was thinking I could at least change the background of the select input to white to make it look close to the previous version. I'll also run it past the product team.

@furious-luke
Copy link
Contributor Author

@scaredcat @tabby-or-not Okay, I've patched up a few of the issues raised, how do we feel about it now?

@scaredcat scaredcat merged commit 5592f24 into master Jul 3, 2018
@scaredcat scaredcat deleted the techdebt/react-select-v2 branch July 3, 2018 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants