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

React Select v2 #2289

Merged
merged 775 commits into from
Jul 23, 2018
Merged

React Select v2 #2289

merged 775 commits into from
Jul 23, 2018

Conversation

JedWatson
Copy link
Owner

@JedWatson JedWatson commented Jan 12, 2018

Updated: See the preview here: http://bit.ly/react-select-v2

v2 issue for discussion: #2208

View the v2 source: https://github.com/JedWatson/react-select/tree/v2

Alpha releases of react-select@2.0.0 are available on npm for preview, and I have opened this PR to help increase visibility of the current state, ci status and netlify preview.

v2 should still be considered experimental, but it's at a point where I would absolutely welcome feedback on the architecture and approach. More examples and documentation coming soon.

PRs and issues specific to the new version should be tagged v2

@JedWatson JedWatson added the v2 label Jan 12, 2018
@JedWatson
Copy link
Owner Author

JedWatson commented Jan 25, 2018

I just published react-select@2.0.0-alpha.2 to npm, this is getting pretty close to a viable implementation. The examples have been updated (see preview link above) and I'd love some feedback on the new architecture.

v2 significantly improves on v1 in several areas:

  • Uses css-in-js with a complete styling API
  • Allows you to completely replace any of the built-in rendering components
  • Is simpler and more extensible (many props will become redundant)
  • More performant

Major work to do before v2 hits feature parity with v1 includes:

  • Form integration (hidden inputs)
  • More robust filtering functionality
  • Async options with Promises (currently supports callbacks)
  • Ability to customise built-in strings
  • Creatable (tags) mode
  • Virtualisation support

It also needs complete documentation and an upgrade guide with changes from v1.x, as well as a lot of tests (and user testing). In the meantime, if you're interested read the example source to see how the new API works.

This was referenced Jan 25, 2018
@JedWatson JedWatson changed the title React Select v2 [do not merge] React Select v2 [work in progress] Jan 31, 2018
@JedWatson
Copy link
Owner Author

Quick update: I published v2.0.0-alpha.3 today and have written up a more comprehensive to-do list here

Getting closer!

@Zertz
Copy link

Zertz commented Feb 2, 2018

Amazing work! We're starting a new project using v2, looking great so far 💯

Only thing so far is that I can't seem to get the loadOptions to work with a Promise but the callback method works just fine.

Copy link
Contributor

@albertogasparin albertogasparin left a comment

Choose a reason for hiding this comment

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

Added few suggestions, nothing mayor found yet.

src/Async.js Outdated
componentDidMount() {
this.mounted = true;
const { defaultOptions } = this.props;
if (defaultOptions === true) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I found this defaultOptions behavior a bit weird. I was expecting it to be falsy or an array, not loading options on mount if true. I know you are saving a prop but I'm wondering if using a dedicated one as in v1 makes the behavior more predictable

Copy link
Owner Author

Choose a reason for hiding this comment

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

I think you're right, it does seem a bit less predictable this way. Happy to add another prop.

src/Async.js Outdated
() => {
this.loadOptions(inputValue, options => {
if (!this.mounted) return;
if (options) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What abut checking also cacheOptions? If it is false then it can skip caching the response altogether

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah that seems like a good thing to do

src/Select.js Outdated
};
};

options.forEach((item, itemIndex) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of forEach I would use reduce, so render is no longer a side effect but it is the result of the loop

Copy link
Owner Author

Choose a reason for hiding this comment

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

@albertogasparin would you be interested in creating a PR for that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure. Here is my take #2359

"classnames": "^2.2.4",
"prop-types": "^15.5.8",
"react-input-autosize": "^2.1.2"
"classnames": "^2.2.5",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still required? Cannot see it being used

.TODO.md Outdated

* [ ] Prevent values from being popped, was `option.clearableValue === false`
* [ ] Scroll behaviour: should we detect parent? how do we handle the footer?
* [ ] Scroll behaviour: can we overscroll up to show the group heading?
Copy link
Contributor

Choose a reason for hiding this comment

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

Another one is: can the user customize scrollIntoView? For instance, if the option group header has position: sticky then the scroll position should account for its height

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah, we should also do some work around handling more complex requirements for rendering the menu (e.g into a Portal)

fontSize: 'inherit',
opacity: isHidden ? 0 : 1,
outline: 0,
padding: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Input might need padding/margin/explicit height when isMulti, as when on a new line on its own is a bit small:
imput-padding

Copy link
Owner Author

Choose a reason for hiding this comment

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

@jossmac can you take a look at this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@JedWatson sure thing, I'll check it out tomorrow.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@JedWatson
Copy link
Owner Author

@Zertz great to hear! I've just implemented Promise support in Async, it'll be available in the upcoming alpha.4 release

@albertogasparin thanks for the review 👌 some good points in there. I'm currently working on a pretty big cleanup (see #2351) and will work through your feedback as soon as I land that.

@Zertz
Copy link

Zertz commented Feb 28, 2018

Fantastic work @JedWatson ! We're releasing alpha.6 in production soon :)

@shulcsm
Copy link

shulcsm commented Mar 12, 2018

Could you release an alpha, it's been a while.

@barbu110
Copy link

barbu110 commented Apr 6, 2018

What about TypeScript typings?

BTW This is an amazing project!

@JedWatson
Copy link
Owner Author

Heads up everyone who's watching this thread - alpha.9 was just released, and we'll be moving into beta shortly (at which point this will be merged into master)

@barbu110

What about TypeScript typings

I'll consider that after the final release of 2.0.0, I know they're helpful but I'm reluctant to introduce anything that needs to be kept in sync after the experience of maintaining both less and scss in v1.x, where only less was actually used by the examples and build. I'm not sure what's worse between no types, and out of sync types.

@bcalik
Copy link

bcalik commented Apr 19, 2018

Thanks for the great effort @JedWatson !! v2 looks really promising. I can't wait to use it on my next project.

@falconmick
Copy link
Contributor

Universal/SSR is broken due to https://github.com/JedWatson/react-select/blob/v2/src/utils.js line 206

I am pulling down locally and working on a patch, will submit PR as soon as I've got SSR working

@JedWatson
Copy link
Owner Author

Great news - React Select 2.0.0-beta.1 is out 🎉

At this point, I think the rewrite is basically complete and don't expect much to change before general release of 2.0. So, I need help making sure it's ready 😃

I'd like to keep it in beta for a couple of weeks, so there's time to get feedback and make sure the upgrade guide / docs are ready before we merge it into master, but all the features I'm planning for 2.0.0 are ready and it's well tested.

Thanks for picking up SSR @falconmick, if anyone else finds issues during beta please open an issue (or even better, PR) with the prefix [v2] in the title.

@falconmick
Copy link
Contributor

I’ll not be able to get onto the issue until late Sunday or early Monday (Aussie time)

gwyneplaine and others added 25 commits July 23, 2018 15:22
Added `closeMenuOnScroll` prop
remove deprecation warning and backward compatibility logic
[V2] Default filterOption prop in Async component instead of passing null
Prefer more descriptive esm word instead of es
update changelog in prep for v2.0.0 release
@JedWatson JedWatson changed the title React Select v2 [work in progress] React Select v2 Jul 23, 2018
@JedWatson JedWatson merged commit 2654ce0 into master Jul 23, 2018
@JedWatson
Copy link
Owner Author

JedWatson commented Jul 23, 2018

OMFG 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet