michael-s-molina opened a new pull request #17169:
URL: https://github.com/apache/superset/pull/17169


   ### SUMMARY
   The objective of this PR is to fix an issue with the order of select options 
when unselecting. It also changes the default sorting algorithm of the `Select` 
component to alphabetical sorting while providing an alternative to the 
component's users to override this behavior. Alphabetical sorting is the most 
common sorting algorithm used by select components in Superset but we do have 
cases where the order is calculated by different criteria. Another objective of 
the solution is to enable server-side sorting.
   
   To fill these objectives, this PR introduced an optional property to the 
`Select` called `sortCompator` that accepts a comparison function and is set to 
alphabetical comparison by default. This function accepts any object that 
adheres to the select options interface which allows custom properties to be 
used when comparing the options. This can be used by server-side sorting, where 
the response can include an `order` field or similar to be used in a custom 
sort comparator.
   
   This comparator is also important to reorder the items after an unselect 
action because we don't know the original order of the elements, especially 
with server-side sorting.
   
   This PR also:
   - Includes test cases for the new property
   - Removes previous sorting related code to avoid duplication
   - Modifies previous sorting related code to use a custom comparator when 
necessary
   
   @geido Can you include this information in the Select API docs?
   
   @yousoph @rusackas @hughhhh @junlincc 
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
https://user-images.githubusercontent.com/70410625/138112216-83e12760-ac0f-4ef0-9e7b-2498474cb0c7.mov
   
   
https://user-images.githubusercontent.com/70410625/138112050-2be25716-b251-488c-858d-689d2ef80402.mov
   
   ### TESTING INSTRUCTIONS
   Check the videos for instructions
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to