Skip to content

async-select-refactor #3372

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

Closed
wants to merge 3 commits into from
Closed

async-select-refactor #3372

wants to merge 3 commits into from

Conversation

gwyneplaine
Copy link
Collaborator

Async Select Refactor

Overview

Previous Async Select was a composition of makeAsyncSelect, manageState and the base Select component in the following order.
makeAsyncSelect(manageState(Select));

This meant the async logic from the exported Async Select was not able to leverage the helpful abstraction of controlled properties like onChange and inputValue that manageState provides.

This PR aims to rectify this by changing this composition order, to the following:
manageState(makeAsyncSelect(Select))

In doing so we are afforded a bunch of niceties:

  • we no longer need to control the inputValue within the state of the Async component, this gets handled by the wrapping logic in manageState.
  • because of the change above, we also no longer need custom onChange logic within the Async component, the most recent inputValue gets read from props; and onChange logic is pushed up as a responsibility of the manageState function. Removing this custom logic means we also resolve [v2] Loading indicator disappears once the menu is opened #3032

AFAIK the api also doesn't change, so this might even be possible to ship as either 2.3.1 or 2.4.0 @JedWatson

Copy link
Collaborator

@jossmac jossmac left a comment

Choose a reason for hiding this comment

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

LGTM -- would prefer @JedWatson has a look too

const promiseOptions = inputValue =>
new Promise(resolve => {
const promiseOptions = inputValue => {
return new Promise(resolve => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this change just for readability?

constructor(props: Props) {
super();
super(props);
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@gwyneplaine gwyneplaine mentioned this pull request Apr 29, 2019
10 tasks
@gwyneplaine gwyneplaine force-pushed the async-select-refactor branch from 3996f29 to c2ecc1d Compare April 29, 2019 01:05
@gwyneplaine gwyneplaine changed the base branch from master to v3.0.0 April 29, 2019 01:05
@gwyneplaine gwyneplaine force-pushed the async-select-refactor branch from c2ecc1d to b2cbdaa Compare April 29, 2019 01:12
@gwyneplaine gwyneplaine force-pushed the v3.0.0 branch 3 times, most recently from 955232b to abbe492 Compare May 27, 2019 06:08
@SimpleCookie
Copy link

I'm not really into this project, but this PR looks good to me.

@bladey bladey added pr/needs-review PRs that need to be reviewed to determine outcome enhancement and removed uncertain labels Jun 4, 2020
@bladey bladey added pr/enhancement PRs that are specifically enhancing the project and removed version-3 labels Jun 24, 2020
@ebonow ebonow added this to the 4.1 milestone Jan 25, 2021
@Methuselah96 Methuselah96 modified the milestones: 4.1, 4.2 Feb 5, 2021
@ebonow ebonow removed this from the 4.2 milestone Feb 14, 2021
@ebonow
Copy link
Collaborator

ebonow commented Mar 10, 2021

@Methuselah96 thoughts on closing this in light of the refactor to TypeScript?

@dcousens dcousens closed this Oct 19, 2022
@dcousens dcousens deleted the async-select-refactor branch October 19, 2022 04:06
@dcousens
Copy link
Collaborator

This is significantly out of date since 4.0.0 and 5.x.y; the changes may still be welcome, but the pull request needs to be significantly updated.
Happy for @gwyneplaine to re-open if they want to rebase the work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/enhancement PRs that are specifically enhancing the project pr/needs-review PRs that need to be reviewed to determine outcome
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants