-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
feat: Improve sorting for new chart dataset select #16414
Conversation
label: this.newLabel(item), | ||
labelText: item.table_name, | ||
})) | ||
.sort((a: { labelText: string }, b: { labelText: string }) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fun fact, this didn't do anything since the selector re-sorts the options again :P Adding a filterSort
prop to the selector is how you actually sort the items in the dropdown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@etr2460 filterSort
only sorts when searching. If the user just opens the select the values will be unsorted if we remove these lines. We'll probably need to apply your sort function here as well 😉
Screen.Recording.2021-08-24.at.7.29.40.AM.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@etr2460 The ideal solution would be to disable the filterSort
when the Select is in async mode and sort the values on the server-side to correctly handle the pagination. This endpoint is not respecting the order_column
and order_direction
props, so we would need to fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, interesting, i didn't even see results rendering when clicking into the modal without typing anything. although maybe that's because in our env we have too many datasets so it didn't render fast enough. i'll see what i can do to fix the sorting for all use cases here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@etr2460 for the scenario where the paginated query with no search (100 results by default) is heavy, we created a prop called fetchOnlyOnSearch
. What we need to do is make it configurable by organizations.
Codecov Report
@@ Coverage Diff @@
## master #16414 +/- ##
==========================================
- Coverage 76.55% 76.54% -0.02%
==========================================
Files 1000 1000
Lines 53483 53495 +12
Branches 6818 6820 +2
==========================================
+ Hits 40945 40947 +2
- Misses 12300 12310 +10
Partials 238 238
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@@ -194,6 +196,8 @@ export default class AddSliceContainer extends React.PureComponent< | |||
this.newLabel = this.newLabel.bind(this); | |||
this.loadDatasources = this.loadDatasources.bind(this); | |||
this.handleFilterOption = this.handleFilterOption.bind(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just replace both filterOption
and filterSort
with match-sorter
. It has worked well for the Explore page Dataset side panel.
This basically means controlling the filtering outside of AntD Select---which should give more consistent filtering behavior across the board.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woah, i haven't seen match-sorter
yet. i think that'll work? although antd select has made it tricky to take control over filtering and sorting. i'll play with it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ktmud Do you think we should try and add this to the default Select component in superset? just apply it across the board?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that'd be ideal. The Select component can provide a matchSorterKey
prop to override the default match-sorting keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ktmud @etr2460 filterSort
is useful when all the values are present in the select. It's less useful when we are using the async version of our select, which is the majority of the cases. In the async version, the sorting should be done on the server-side before the pagination to ensure the correct results are returned. Client-side sorting on paginated requests can produce wrong results. We can use match-sorter
for the static version but so far we haven't found any case where the default sorting wasn't sufficient. I think the best way to fix this is to make the endpoint respect the sorting parameters and implement the exact match behavior on the server-side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, bumping exact matches is probably good enough for now.
It'd definitely be nice to have paginated backend searches. Hopefully we'll come up with a solution that's generalized enough even for omni-searches in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going down this path, then maybe we need elasticsearch on the backend :P mysql isn't great for search
I'd love to make this an optional search backend! 🍻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we all agree here. Thanks @villebro ! do you think i should close this pr then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@etr2460 I have a POC in mind but it would introduce a fairly significant change on FAB, so I want to discuss it first with Daniel before starting the work, and he's currently on PTO. I don't expect my POC to be ready for another few weeks (will require review and a new release), so if this is needed in the interim then we can merge this IMO unless @michael-s-molina has some objections.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@villebro I don't have any objections as a temporary solution. We can come back later and remove the client-side sorting. We'll probably need to do that anyway with other selects.
Before merging, we need to also sort the values when the user opens the select as stated here #16414 (comment)
@villebro based on @michael-s-molina's comment are you ok moving forward with said change, especially given—per @etr2460's PR description—the UX is severely impacted at Airbnb or likely any other installation which contains a large number of datasets etc. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue |
SUMMARY
#16200 updated the add chart page and as a side effect started showing virtual datasets in the dropdown. This was probably a good thing all told, but at Airbnb we had a bunch of virtual datasets with similar names to physical datasets that then made it difficult/impossible to find the original physical dataset in the selector.
This change will elevate an exact match dataset name to the top of the selector if one exists.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
created datasets with very similar names, ensured that the one with an exact matching name appears first
ADDITIONAL INFORMATION
to: @michael-s-molina @ktmud @suddjian