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

Make ModulesSelect remain open after selection #655

Merged

Conversation

eugenood
Copy link
Contributor

@eugenood eugenood commented Jan 3, 2018

This PR is made with respect to #598.

I had implemented @yangshun original solution:

One solution I have is to retain the search term and results screen so that the Added label appears and the user will know that the operation was successful. I think it's ok to leave the search term and results there as people usually add modules from the same faculty anyway.

@mods-bot
Copy link

mods-bot commented Jan 3, 2018

Deploy preview ready!

Built with commit 822b2ca

https://deploy-preview-655--nusmods.netlify.com

Copy link
Member

@ZhangYiJiang ZhangYiJiang left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Do take note of the bugs and see if you can fix them.

};

onStateChange = (changes: any) => {
if (Object.prototype.hasOwnProperty.call(changes, 'inputValue')) {
Copy link
Member

Choose a reason for hiding this comment

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

Just use _.has for this. Also, combine the two if statements

if (Object.prototype.hasOwnProperty.call(changes, 'inputValue')) {
if (!Object.prototype.hasOwnProperty.call(changes, 'selectedItem')) {
this.setState({
inputValue: changes.inputValue,
Copy link
Member

Choose a reason for hiding this comment

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

I see two bugs (not entirely sure if they are caused by this specific line, will investigate a bit further when I have time)

  • When blurring after selecting an item, this causes the input value to be set to the last select item's value (ie. it's module code), not the last input value
  • Cursor position is reset if you try to edit the middle of the search query

@ZhangYiJiang
Copy link
Member

Oh, and ignore the CircleCI failure - that's because of a config error on our part I think

- Fix cursor jumping to the end of the input
- Refactor `ModulesSelect`
@eugenood
Copy link
Contributor Author

eugenood commented Jan 3, 2018

Here's what I changed in the latest commit 4e95fac:

  • Turns out the cursor issue is a known issue. I had fixed it accordingly.
  • According to downshift documentation, props of rendered element should be passed as arguments into the prop getter. I had changed it accordingly.
  • I refactored the class.

There is, however, a bug on mobile that I haven't figure out a fix. If you switch to numeric keyboard and type a digit, it will return back to the alpha keyboard.

isOpen: boolean,
isModalOpen: boolean,
inputValue: string,
selectedItem: any,
Copy link
Member

Choose a reason for hiding this comment

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

This should probably match the type of item property that was passed into getItemProp, which is ModuleCode. Since it is nullable, this should be ?ModuleCode

@yangshun
Copy link
Member

yangshun commented Jan 3, 2018

@nexolute Good stuff, thanks for the PR!

@yangshun yangshun changed the title Make ModulesSelect remains open after selection Make ModulesSelect remain open after selection Jan 4, 2018
@coveralls
Copy link

Coverage Status

Coverage increased (+0.6%) to 53.455% when pulling 7b04ffd on nexolute:modules-select-feedback into af40134 on nusmodifications:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 52.786% when pulling 285e835 on nexolute:modules-select-feedback into af40134 on nusmodifications:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 52.716% when pulling 1f17e99 on nexolute:modules-select-feedback into af40134 on nusmodifications:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 52.716% when pulling 30a8d4b on nexolute:modules-select-feedback into af40134 on nusmodifications:master.

@nusmodifications nusmodifications deleted a comment from coveralls Jan 9, 2018
@nusmodifications nusmodifications deleted a comment from coveralls Jan 9, 2018
@nusmodifications nusmodifications deleted a comment from coveralls Jan 9, 2018
@nusmodifications nusmodifications deleted a comment from coveralls Jan 9, 2018
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 52.692% when pulling 0222523 on nexolute:modules-select-feedback into 43cdfe8 on nusmodifications:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 52.692% when pulling 9691dc0 on nexolute:modules-select-feedback into 43cdfe8 on nusmodifications:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 53.118% when pulling 5ce199d on nexolute:modules-select-feedback into 9091543 on nusmodifications:master.

Copy link
Member

@taneliang taneliang left a comment

Choose a reason for hiding this comment

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

Could we add a background color for the dropdown? On iPad, you can scroll beyond the ends of the list and peek at the content behind it. This bug is present in master but we should probably just fix it here.

440ed0fa-7475-42fb-ab50-93d810861875

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 53.118% when pulling 058995c on nexolute:modules-select-feedback into 9091543 on nusmodifications:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 53.151% when pulling 822b2ca on nexolute:modules-select-feedback into bcd198c on nusmodifications:master.

@ZhangYiJiang ZhangYiJiang merged commit b15733c into nusmodifications:master Jan 9, 2018
@ZhangYiJiang
Copy link
Member

@nexolute Thanks for this PR, and sorry it took so long!

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

6 participants