Skip to content

Commit

Permalink
Merge pull request #3868 from marmelab/fix-demo-usermenu
Browse files Browse the repository at this point in the history
[RFR] Fix custom user menu does not close after selecting an item in the demo
  • Loading branch information
fzaninotto authored Oct 28, 2019
2 parents 0630de5 + 3f29f0c commit a81cbb9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
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

0 comments on commit a81cbb9

Please sign in to comment.