Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] Fix custom user menu does not close after selecting an item in the demo #3868

Merged
merged 1 commit into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions docs/Theming.md
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,19 @@ You can replace the default user menu by your own by setting the `userMenu` prop
import { AppBar, UserMenu, MenuItemLink } from 'react-admin';
import SettingsIcon from '@material-ui/icons/Settings';

const ConfigurationMenu = forwardRef(({ onClick }, ref) => (
<MenuItemLink
ref={ref}
to="/configuration"
primaryText={Configuration}
leftIcon={<SettingsIcon />}
onClick={onClick} // close the menu on click
/>
));

const MyUserMenu = props => (
<UserMenu {...props}>
<MenuItemLink
to="/configuration"
primaryText="Configuration"
leftIcon={<SettingsIcon />}
/>
<ConfigurationMenu />
</UserMenu>
);

Expand Down
3 changes: 2 additions & 1 deletion examples/demo/src/layout/AppBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ const useStyles = makeStyles({
},
});

const ConfigurationMenu = forwardRef((_, ref) => {
const ConfigurationMenu = forwardRef((props, ref) => {
const translate = useTranslate();
return (
<MenuItemLink
ref={ref}
to="/configuration"
primaryText={translate('pos.configuration')}
leftIcon={<SettingsIcon />}
onClick={props.onClick}
/>
);
});
Expand Down