You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/08/20 13:06:30 UTC
[GitHub] [superset] kgabryje commented on a change in pull request #16362: feat(explore): improve typing for Dnd controls and add logging
kgabryje commented on a change in pull request #16362:
URL: https://github.com/apache/superset/pull/16362#discussion_r692930685
##########
File path: superset-frontend/src/explore/components/DatasourcePanel/index.tsx
##########
@@ -193,61 +194,64 @@ export default function DataSourcePanel({
const DEFAULT_MAX_COLUMNS_LENGTH = 50;
const DEFAULT_MAX_METRICS_LENGTH = 50;
- const search = useCallback(
- debounce((value: string) => {
- if (value === '') {
- setList({ columns, metrics });
- return;
- }
- setList({
- columns: matchSorter(columns, value, {
- keys: [
- {
- key: 'verbose_name',
- threshold: rankings.CONTAINS,
- },
- {
- key: 'column_name',
- threshold: rankings.CONTAINS,
- },
- {
- key: item =>
- [item.description, item.expression].map(
- x => x?.replace(/[_\n\s]+/g, ' ') || '',
- ),
- threshold: rankings.CONTAINS,
- maxRanking: rankings.CONTAINS,
- },
- ],
- keepDiacritics: true,
- }),
- metrics: matchSorter(metrics, value, {
- keys: [
- {
- key: 'verbose_name',
- threshold: rankings.CONTAINS,
- },
- {
- key: 'metric_name',
- threshold: rankings.CONTAINS,
- },
- {
- key: item =>
- [item.description, item.expression].map(
- x => x?.replace(/[_\n\s]+/g, ' ') || '',
- ),
- threshold: rankings.CONTAINS,
- maxRanking: rankings.CONTAINS,
- },
- ],
- keepDiacritics: true,
- baseSort: (a, b) =>
- Number(b.item.is_certified) - Number(a.item.is_certified) ||
- String(a.rankedValue).localeCompare(b.rankedValue),
- }),
- });
- }, FAST_DEBOUNCE),
- [columns, metrics],
+ const search = debounce(
Review comment:
Is there a reason why you changed the order here? According to https://dmitripavlutin.com/react-throttle-debounce/ `useCallback` should go first (although it seems that what we had here wasn't fully correct as we should wrap debounce function in useMemo...)
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org