LevisNgigi commented on code in PR #35683:
URL: https://github.com/apache/superset/pull/35683#discussion_r2445460304


##########
superset-frontend/plugins/plugin-chart-ag-grid-table/src/AgGridTable/components/CustomHeader.tsx:
##########
@@ -70,7 +76,40 @@ const CustomHeader: React.FC<CustomHeaderParams> = ({
   const [isFilterVisible, setFilterVisible] = useState(false);
   const [isMenuVisible, setMenuVisible] = useState(false);
   const filterRef = useRef<HTMLDivElement>(null);
-  const isFilterActive = column?.isFilterActive();
+  const filterButtonRef = useRef<HTMLDivElement>(null);
+  // Use activeFilterColumns from context as reliable backup for AG Grid's 
isFilterActive
+  const isFilterActive =
+    column?.isFilterActive() ||
+    (colId ? activeFilterColumns?.has(colId) : false);
+
+  const focusFilterInput = useCallback((position?: 'first' | 'second') => {
+    setTimeout(() => {
+      if (!filterRef.current) return;
+
+      const filterBodies =
+        filterRef.current.querySelectorAll<HTMLElement>('.ag-filter-body');
+
+      if (filterBodies.length === 0) return;
+
+      let targetFilterBody: HTMLElement | null = null;
+
+      if (position === 'second' && filterBodies?.length > 1) {
+        targetFilterBody = filterBodies[1];
+      } else if (position === 'first' && filterBodies?.length > 0) {
+        targetFilterBody = filterBodies[0];
+      }
+
+      if (!targetFilterBody) return;
+
+      const input = targetFilterBody.querySelector<HTMLInputElement>(
+        'input:not([type="checkbox"]):not([type="radio"]), textarea',
+      );
+
+      if (input) {
+        input.focus();
+      }
+    }, 100);

Review Comment:
   The setTimeout values (100ms / 200ms below in the use effect) are a bit 
arbitrary.
   It would be helpful to define constants or add a small comment explaining 
the delay.



##########
superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts:
##########
@@ -290,6 +297,52 @@ const buildQuery: BuildQuery<TableChartFormData> = (
           ],
         };
       }
+
+      // Add AG Grid column filters from ownState (non-metric filters only)
+      if (
+        ownState.agGridSimpleFilters &&
+        ownState.agGridSimpleFilters.length > 0

Review Comment:
   ```suggestion
           ownState.agGridSimpleFilters.length
   ```



##########
superset-frontend/plugins/plugin-chart-ag-grid-table/src/types.ts:
##########
@@ -132,12 +132,23 @@ export type SearchOption = {
   label: string;
 };
 
+export interface AgGridColumnFilter {
+  col: string;
+  op: string;
+  val: string | number | boolean | null | (string | number)[];
+}
+
 export interface ServerPaginationData {
   pageSize?: number;
   currentPage?: number;
   sortBy?: SortByItem[];
   searchText?: string;
   searchColumn?: string;
+  agGridFilterModel?: Record<string, any>; // Raw AG Grid filter model for 
state restoration

Review Comment:
   Could there be a more specific type instead of any?



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