diff --git a/docs/SolarLayout.md b/docs/SolarLayout.md index d3ca0b1268c..87be3b111bc 100644 --- a/docs/SolarLayout.md +++ b/docs/SolarLayout.md @@ -862,3 +862,89 @@ export const App = () => ( | `className` | Optional | string | | A class name to apply to the AppBar container. | | `color` | Optional | string | 'secondary' | The color of the AppBar. Can be primary, secondary, or inherit. Defaults to secondary. | | `container` | Optional | ElementType | HideOnScroll | The component used for the root node. | + +## Use It With `` + +The `` component works perfectly when used inside the [``](https://marmelab.com/ra-enterprise/modules/ra-navigation#solarlayout) menu. + + + +The `useSolarSidebarActiveMenu` hook combined with the `onNavigate` prop allow you to close the `` when the user selects an element in the result. + +Here is an implementation example: + +{% raw %} +```tsx +import { Admin } from 'react-admin'; +import { Box } from '@mui/material'; +import SearchIcon from '@mui/icons-material/Search'; +import AlbumIcon from '@mui/icons-material/Album'; +import Groups3Icon from '@mui/icons-material/Groups3'; +import { + SolarLayout, + SolarLayoutProps, + SolarMenu, + useSolarSidebarActiveMenu, +} from '@react-admin/ra-navigation'; +import { SearchWithResult } from '@react-admin/ra-search'; +import { searchDataProvider } from './searchDataProvider'; + +const MySolarLayout = (props: SolarLayoutProps) => ( + +); + +const MySolarMenu = () => ( + }> + } + label="resources.stores.name" + /> + } + label="resources.events.name" + /> + +); + +const CustomBottomToolbar = () => ( + <> + + + +); + +const SearchMenuItem = () => { + const [, setActiveMenu] = useSolarSidebarActiveMenu(); + const handleClose = () => { + setActiveMenu(''); + }; + + return ( + } + label="Search" + name="search" + subMenu={ + + + + } + data-testid="search-button" + /> + ); +}; + +export const App = () => ( + + {/*...*/} + +); +``` +{% endraw %}