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

Feature/new selector #3332

Merged
merged 16 commits into from
Mar 9, 2018
Merged

Feature/new selector #3332

merged 16 commits into from
Mar 9, 2018

Conversation

edbrett
Copy link
Contributor

@edbrett edbrett commented Mar 7, 2018

The problem

We were using react-select-me, a selector library that handles the majority of use cases for a dropdown selector. This selector doesn't support keyboard events, and in order to add grouping and interaction to the options list we would need to do significant work to handle all the use cases.

The solution

Thanks to the wonderful library Downshift we can now make truly flexible selectors, autocompletes, etc etc. Downshift gives us the control over the data returned, and we build the render. In this PR, I have created a react-select like dropdown using Downshift which accounts for all the edge cases that GFW requires:

  • Clearable
  • Searchable
  • Acts as dropdown
  • Grouping (with custom navigation)
  • Control over when the selector should close
  • Custom keyboard events and controls

BONUS

Instead of using ./bin/server you can now use npm start to start the server

Demo

2018-03-07 15 47 25

Notes

This is a starting point. It would be good if we can work on improving this selector and any bugs you can find.

@edbrett edbrett requested review from pjosh and sorodrigo March 7, 2018 14:50
Copy link
Contributor

@pjosh pjosh left a comment

Choose a reason for hiding this comment

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

wow Downshift!! Great choise @edbrett 😄
It only worries me that the dropdown component is so complex now. I've see that you are encapsulating some parts of the dropdown logic in differents functions. What do you think about make individual sub-components with that? That should be reduce quite the component complexity.

Copy link
Contributor

@pjosh pjosh left a comment

Choose a reason for hiding this comment

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

We must remove this line: import 'react-select-me/lib/ReactSelectMe.css'; in app/javascript/pages/country/index.js

@edbrett
Copy link
Contributor Author

edbrett commented Mar 8, 2018

You are completely right! I will try to make it more modular :)

@pjosh
Copy link
Contributor

pjosh commented Mar 9, 2018

Much better now! Thx @edbrett 👏 👏

@edbrett edbrett merged commit ad93873 into develop Mar 9, 2018
@edbrett edbrett deleted the feature/new-selector branch March 9, 2018 11:05
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.

2 participants