Skip to content

Commit

Permalink
Merge pull request #4994 from marmelab/fix-logout-button-tag-element
Browse files Browse the repository at this point in the history
Fix <LogoutButton >should not render as a <li> in Mobile menu
  • Loading branch information
djhi authored Jun 30, 2020
2 parents 9a2371d + c216894 commit 10f7c7d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/ra-ui-materialui/src/auth/Logout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import * as React from 'react';
import { useCallback, FunctionComponent, ReactElement } from 'react';
import PropTypes from 'prop-types';
import { ListItemIcon, MenuItem, makeStyles } from '@material-ui/core';
import {
ListItemIcon,
MenuItem,
useMediaQuery,
makeStyles,
} from '@material-ui/core';
import { MenuItemProps } from '@material-ui/core/MenuItem';
import { Theme } from '@material-ui/core/styles';

Expand Down Expand Up @@ -41,6 +46,9 @@ const LogoutWithRef: FunctionComponent<
...rest
} = props;
const classes = useStyles(props);
const isXSmall = useMediaQuery((theme: Theme) =>
theme.breakpoints.down('xs')
);
const translate = useTranslate();
const logout = useLogout();
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand All @@ -53,6 +61,7 @@ const LogoutWithRef: FunctionComponent<
className={classnames('logout', classes.menuItem, className)}
onClick={handleClick}
ref={ref}
component={isXSmall ? 'span' : 'li'}
{...rest}
>
<ListItemIcon className={classes.icon}>
Expand Down

0 comments on commit 10f7c7d

Please sign in to comment.