villebro commented on code in PR #23664:
URL: https://github.com/apache/superset/pull/23664#discussion_r1164367974


##########
superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx:
##########
@@ -116,36 +122,87 @@ export default function DrillByModal({
   filters,
   formData,
   groupbyFieldName = 'groupby',
+  adhocFilterFieldName = 'adhoc_filters',
   onHideModal,
 }: DrillByModalProps) {
   const theme = useTheme();
-  const [chartDataResult, setChartDataResult] = useState<QueryData[]>();
-  const [drillByDisplayMode, setDrillByDisplayMode] = useState<DrillByType>(
-    DrillByType.Chart,
+
+  const initialGroupbyColumns = useMemo(
+    () =>
+      ensureIsArray(formData[groupbyFieldName])
+        .map(colName =>
+          dataset.columns?.find(col => col.column_name === colName),
+        )
+        .filter(isDefined),
+    [dataset.columns, formData, groupbyFieldName],
   );
+
+  const { displayModeToggle, drillByDisplayMode } = useDisplayModeToggle();
+  const [chartDataResult, setChartDataResult] = useState<QueryData[]>();
   const [datasourceId] = useMemo(
     () => formData.datasource.split('__'),
     [formData.datasource],
   );
 
-  const [currentColumn, setCurrentColumn] = useState(column);
+  // currentColumn can be an array when the original chart is grouped by 
multiple
+  // columns and user navigates back to the original chart by clicking the 
first
+  // breadcrumb
+  const [currentColumn, setCurrentColumn] = useState<
+    Column | Column[] | undefined
+  >(column);

Review Comment:
   Just a thought - would it potentially simplify the code, if we'd do 
something like this (we'd also do something similar in those other similar code 
blocks):
   ```typescript
     const [currentColumns, setCurrentColumns] = 
useState(ensureIsArray(column));
   ```
   The we wouldn't have to jump between `currentColumn` and `currentColumns` or 
worry about it potentially being `undefined`.



-- 
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-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to