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 Categories sort compareFunction return to -1 from 0 in Picker component #164

Merged

Conversation

shoken0x
Copy link

@shoken0x shoken0x commented Feb 15, 2018

I tried to use Picker component with include props.

<Picker
  include={["foods", "nature"]}
  onClick={this._updateEmoji.bind(this)}
  showPreview={false} />

But it seems that sort order is different depending on browsers. It is a result by Desktop Chrome ( Mobile device emulator mode ) and Mobile Chrome ( iPhone X ).

Desktop Chrome ( emulator mode ) Mobile Chrome ( iPhone X )
v64.0.3282.140 v64.0.3282.112
return ["foods", "nature"] return ["nature", "foods"]
2018-02-15 18 58 36 2018-02-15 18 58 36

I think this document in MDN is related.

Array.prototype.sort() ,

If compareFunction(a, b) returns 0, leave a and b unchanged with respect to each other, but sorted with respect to all different elements. Note: the ECMAscript standard does not guarantee this behaviour, and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.

This PR simply change return of compareFunction to -1 from 0, it seems to be working fine.

Thanks for this great component!

@EtienneLem EtienneLem merged commit 1c1fe76 into missive:master Feb 15, 2018
@EtienneLem
Copy link
Member

Nice catch, thanks! 🤘

@shoken0x
Copy link
Author

@EtienneLem 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