Skip to content

fixed async pagination bugs#3

Open
stepbackj wants to merge 2 commits intoTheSharpieOne:feature/async-paginationfrom
stepbackj:async-pagination-fixes
Open

fixed async pagination bugs#3
stepbackj wants to merge 2 commits intoTheSharpieOne:feature/async-paginationfrom
stepbackj:async-pagination-fixes

Conversation

@stepbackj
Copy link

@stepbackj stepbackj commented Oct 20, 2017

Really essential feature so I decided to work off your fork. Found a couple of issues that I've fixed for my personal use

@stepbackj stepbackj force-pushed the async-pagination-fixes branch from b983c1c to 216b7d5 Compare October 20, 2017 00:09
@stepbackj
Copy link
Author

stepbackj commented Jan 2, 2018

@TheSharpieOne can we have this merged? I will rebase once you're open to it. There are a few ways you can break the paginated async react-select component and this pull request addresses those edge cases.

First edge case deals with deleting characters from the input quickly (holding down backspace produces a bug). The component will stay in loading state indefinitely.

Second edge case deals with how the react-select component handles refetching if the select begins to run out of options. Currently the only thing that fires an AJAX call is a scroll, which won't happen if the user selects all the available options.

this.props.onChange(value);

if (this.props.pagination) {
let remainingOptions = this.state.options.length - value.length;
Copy link
Owner

@TheSharpieOne TheSharpieOne Jan 2, 2018

Choose a reason for hiding this comment

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

What is value here? It can be a string or an object as well as an array. When it is not an array, this line doesn't make much sense.

Copy link
Author

Choose a reason for hiding this comment

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

ah, you're correct. these fixes were specifically for my use case which was multi-select async pagination. let me test out some of the other edge cases and get back to you with another commit.

onInputChange(transformedInputValue);
}

let oldInputValue = this.state.inputValue;
Copy link
Owner

Choose a reason for hiding this comment

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

setting state is async. This with the check two lines below will lead to bugs where the loadOptions is not called when it should have been.

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.

3 participants