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

Fix show selected on top for combobox #84

Merged
merged 4 commits into from
Feb 15, 2018
Merged

Conversation

iwiznia
Copy link
Contributor

@iwiznia iwiznia commented Feb 14, 2018

@tgolen , will you please review this?

There were 2 issues:

  1. When you had many entries, the showSelectedOnTop was not working because we got the first X before sorting them.
  2. When setting the value to '' the component thought we were selecting the Viewing first ${this.props.maxItemsToShow} items. Search to see more. because we created that option with value of ''.

Needed for

https://github.com/Expensify/Expensify/issues/73200#event-1471060712

Tests

  1. Tested attendee selector with 10k entries and checked that selected options always show on top, make sure that after clearing the value, the Viewing first... text is not shown in the combobox as selected.

…f items), do not treat fake created items as real
@iwiznia iwiznia self-assigned this Feb 14, 2018
@iwiznia iwiznia requested a review from tgolen February 14, 2018 10:14
}))
.sortBy((o) => {
// Fake entries go to the bottom and selected entries go to the top only if alwaysShowSelectedOnTop was passed
if (o.isFake) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is going to start to get messy. What happens when someone else wants one of the fake options to be at the top? Would it be better to have isFake and listLast (or maybe a better name)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Another thought... what if we use null for the value instead of an isFake property?

Copy link
Contributor Author

@iwiznia iwiznia Feb 14, 2018

Choose a reason for hiding this comment

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

. what if we use null for the value instead of an isFake property?

I can try that but it wouldn't help for the sorting thing. Also, we would have the same problem if we ever pass null as a valid value for the option.

What happens when someone else wants one of the fake options to be at the top?

It's funny that you ask that because as soon as I sent this PR, I saw this... so if we want to do that (and not have the change apply to all selectors) then we need a new prop passed to the component.

Would it be better to have isFake and listLast (or maybe a better name)?

What do you mean?

Copy link
Contributor

Choose a reason for hiding this comment

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

I can try that but it wouldn't help for the sorting thing

Yeah, I know that doesn't help for the sorting, but I'm trying to separate the two (I don't think sorting should be based off of anything except something related to sorting).

What do you mean?

Use listLast to solve point 1 from the PR description and use isFake (or null value) to solve point 2.

@iwiznia
Copy link
Contributor Author

iwiznia commented Feb 15, 2018

Updated

Copy link
Contributor

@tgolen tgolen left a comment

Choose a reason for hiding this comment

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

Thanks!

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