This is an automated email from the ASF dual-hosted git repository.

richardfogaca pushed a commit to branch feat/auto-refresh-dashboard
in repository https://gitbox.apache.org/repos/asf/superset.git

commit c7cbd49e9af87312272b8e45ddc891e681aa1ff3
Author: richard <[email protected]>
AuthorDate: Thu Feb 5 21:42:38 2026 -0300

    fix: remove deprecated testing library hook and simplify menu ref caching
    
    - Replace @testing-library/react-hook with @testing-library/react
    - Remove redundant menuRef caching (menu already memoized via useMemo)
    - Simplify hook return statement
---
 .../AutoRefreshStatus/StatusIndicatorDot.test.tsx     | 13 +++++++------
 .../Header/useHeaderActionsDropdownMenu.tsx           | 19 ++-----------------
 2 files changed, 9 insertions(+), 23 deletions(-)

diff --git 
a/superset-frontend/src/dashboard/components/AutoRefreshStatus/StatusIndicatorDot.test.tsx
 
b/superset-frontend/src/dashboard/components/AutoRefreshStatus/StatusIndicatorDot.test.tsx
index 1ec06e4ad3f..544dbf2a2c4 100644
--- 
a/superset-frontend/src/dashboard/components/AutoRefreshStatus/StatusIndicatorDot.test.tsx
+++ 
b/superset-frontend/src/dashboard/components/AutoRefreshStatus/StatusIndicatorDot.test.tsx
@@ -20,6 +20,11 @@ import { render, screen, act } from 
'spec/helpers/testing-library';
 import { StatusIndicatorDot } from './StatusIndicatorDot';
 import { AutoRefreshStatus } from '../../types/autoRefresh';
 
+afterEach(() => {
+  jest.runOnlyPendingTimers();
+  jest.useRealTimers();
+});
+
 test('renders with success status', () => {
   render(<StatusIndicatorDot status={AutoRefreshStatus.Success} />);
   const dot = screen.getByTestId('status-indicator-dot');
@@ -64,7 +69,7 @@ test('has correct accessibility attributes', () => {
   expect(dot).toHaveAttribute('aria-label', 'Auto-refresh status: success');
 });
 
-test('fetching status updates immediately without debounce', async () => {
+test('fetching status updates immediately without debounce', () => {
   jest.useFakeTimers();
 
   const { rerender } = render(
@@ -76,11 +81,9 @@ test('fetching status updates immediately without debounce', 
async () => {
 
   const dot = screen.getByTestId('status-indicator-dot');
   expect(dot).toHaveAttribute('data-status', AutoRefreshStatus.Fetching);
-
-  jest.useRealTimers();
 });
 
-test('debounces non-fetching status changes to prevent flickering', async () 
=> {
+test('debounces non-fetching status changes to prevent flickering', () => {
   jest.useFakeTimers();
 
   const { rerender } = render(
@@ -102,8 +105,6 @@ test('debounces non-fetching status changes to prevent 
flickering', async () =>
   // Now should be error
   dot = screen.getByTestId('status-indicator-dot');
   expect(dot).toHaveAttribute('data-status', AutoRefreshStatus.Error);
-
-  jest.useRealTimers();
 });
 
 test('accepts custom size prop', () => {
diff --git 
a/superset-frontend/src/dashboard/components/Header/useHeaderActionsDropdownMenu.tsx
 
b/superset-frontend/src/dashboard/components/Header/useHeaderActionsDropdownMenu.tsx
index c0c8a9a660c..dcf31470093 100644
--- 
a/superset-frontend/src/dashboard/components/Header/useHeaderActionsDropdownMenu.tsx
+++ 
b/superset-frontend/src/dashboard/components/Header/useHeaderActionsDropdownMenu.tsx
@@ -17,7 +17,7 @@
  * under the License.
  */
 import type { Dispatch, ReactElement, SetStateAction } from 'react';
-import { useState, useEffect, useCallback, useMemo, useRef } from 'react';
+import { useState, useEffect, useCallback, useMemo } from 'react';
 import { useSelector } from 'react-redux';
 import { useHistory } from 'react-router-dom';
 import { Menu, MenuItem } from '@superset-ui/core/components/Menu';
@@ -72,7 +72,6 @@ export const useHeaderActionsMenu = ({
   Dispatch<SetStateAction<boolean>>,
 ] => {
   const [isDropdownVisible, setIsDropdownVisible] = useState(false);
-  const menuRef = useRef<React.ReactElement | null>(null);
   const history = useHistory();
   const directPathToChild = useSelector(
     (state: RootState) => state.dashboardState.directPathToChild,
@@ -339,19 +338,5 @@ export const useHeaderActionsMenu = ({
     userCanShare,
   ]);
 
-  if (!menuRef.current) {
-    menuRef.current = menu;
-  }
-
-  useEffect(() => {
-    if (!isDropdownVisible) {
-      menuRef.current = menu;
-    }
-  }, [isDropdownVisible, menu]);
-
-  return [
-    isDropdownVisible && menuRef.current ? menuRef.current : menu,
-    isDropdownVisible,
-    setIsDropdownVisible,
-  ];
+  return [menu, isDropdownVisible, setIsDropdownVisible];
 };

Reply via email to