fix(mobile): address bito review feedback on mobile PR

- Rename DashboardList's double-negative isNotMobile to isMobile and
  flip its usages for clarity.
- Home.mobile.test.tsx: capture and restore the matchMedia mock in
  afterAll so it doesn't leak past this test file.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
rusackas
2026-08-04 23:25:33 -07:00
co-authored by Claude Opus 4.8
parent 4be8742067
commit 3cd67206df
2 changed files with 9 additions and 5 deletions
@@ -179,7 +179,7 @@ const DASHBOARD_COLUMNS_TO_FETCH = [
function DashboardList(props: DashboardListProps) {
const { addDangerToast, addSuccessToast, user } = props;
const isNotMobile = !useIsMobile();
const isMobile = useIsMobile();
const theme = useTheme();
const [mobileFiltersOpen, setMobileFiltersOpen] = useState(false);
const { roles } = useSelector<any, UserWithPermissionsAndRoles>(
@@ -859,7 +859,7 @@ function DashboardList(props: DashboardListProps) {
name={t('Dashboards')}
buttons={subMenuButtons}
leftIcon={
!isNotMobile ? (
isMobile ? (
<Button
buttonStyle="link"
onClick={() => setMobileFiltersOpen(true)}
@@ -967,12 +967,12 @@ function DashboardList(props: DashboardListProps) {
? 'card'
: 'table'
}
forceViewMode={!isNotMobile ? 'card' : undefined}
forceViewMode={isMobile ? 'card' : undefined}
enableBulkTag={enableBulkTag}
bulkTagResourceName="dashboard"
mobileFiltersOpen={mobileFiltersOpen}
setMobileFiltersOpen={
!isNotMobile ? setMobileFiltersOpen : undefined
isMobile ? setMobileFiltersOpen : undefined
}
mobileFiltersDrawerTitle={t('Search Dashboards')}
/>
@@ -39,7 +39,7 @@ jest.mock('@superset-ui/core', () => ({
}));
// Simulate a mobile viewport for the useIsMobile hook
mockMobileMatchMedia();
const restoreMatchMedia = mockMobileMatchMedia();
// API mocks
const chartsEndpoint = 'glob:*/api/v1/chart/?*';
@@ -128,6 +128,10 @@ afterEach(() => {
fetchMock.clearHistory();
});
afterAll(() => {
restoreMatchMedia();
});
test('Mobile view - renders Dashboards panel', async () => {
await renderWelcome();
expect(await screen.findByText('Dashboards')).toBeInTheDocument();