-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
[Enhancement] Add menuRenderer
prop to support windowing for large lists
#859
Conversation
…done via custom renderMenu functoin
Changes Unknown when pulling 03b3f00 on bvaughn:master into * on JedWatson:master*. |
Changes Unknown when pulling 071ae88 on bvaughn:master into * on JedWatson:master*. |
Changes Unknown when pulling 143bd64 on bvaughn:master into * on JedWatson:master*. |
Changes Unknown when pulling 9e11ce9 on bvaughn:master into * on JedWatson:master*. |
@@ -250,6 +296,7 @@ For multi-select inputs, when providing a custom `filterOptions` method, remembe | |||
optionRenderer | func | undefined | function which returns a custom way to render the options in the menu | |||
options | array | undefined | array of options | |||
placeholder | string\|node | 'Select ...' | field placeholder, displayed when there's no value | |||
renderMenu | func | undefined | Renders a custom menu with options; accepts the following named parameters: `renderMenu({ focusedOption, focusOption, options, selectValue, valueArray })` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe menuRenderer
would be better choice since it follows existing naming convention of optionRenderer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed. Thanks for the suggestion.
Nice work! 👍 I think it would be good idea not to include |
Truth. I wanted a live demo to point out so I had to push them to my fork. But maybe I'll clean up this PR and use another branch for the demo. Thanks for the input :) |
renderMenu
property for custom Menu renderingmenuRenderer
prop to support windowing for large lists
Changes Unknown when pulling 3b591bf on bvaughn:master into * on JedWatson:master*. |
Changes Unknown when pulling 3b591bf on bvaughn:master into * on JedWatson:master*. |
Okay. Dist files have all been removed. Only large files still around are the example cities list. |
Changes Unknown when pulling 9e18d92 on bvaughn:master into * on JedWatson:master*. |
Changes Unknown when pulling a64c43f on bvaughn:master into * on JedWatson:master*. |
Changes Unknown when pulling a64c43f on bvaughn:master into * on JedWatson:master*. |
This looks fantastic @bvaughn! Thanks for the PR, and for owning the feature :) |
This is great. It seems like it should be possible to use |
👍 to this. This is way more flexible than the |
I believe this PR resolves the following open issues: #554, #674, #739, #771, #807.
This PR adds support for windowing libraries like react-virtualized to be used to render large lists of options. It is similar to the approach mentioned in PR #763 but it avoids creating all of the menu options when rendering and so it performs better.
The size of the PR is mostly due to the fact that it contains a JSON data file of the largest 1,000 cities in Europe (used to demonstrate custom menu windowing). The actual changes to the
Select
component were very minimal (~40 new lines).This change-set includes:
renderMenu
prop added toSelect
component.test/Select-test.js
for new property. (Previous tests all pass.)Note that react-virtualized was added to the
devDependencies
section (notdependencies
) so it could be used in the example to demonstrate a more efficient way of rendering select menus with large amounts of data.If this PR gets merged, or one like it, I plan to release a small adapter library with a single HOC that provides the react-virtualized drop-down menu automatically and passes through other props to
Select
. (In other words, I'm happy to take over the ownership of the feature.)