fix: Fixed 10080 settings sidebar scrolling issue (#10471)

* fix: #10080 settings sidebar scrolling issue

* fix: type error

Signed-off-by: Udit Takkar <[email protected]>

* Fixed type error

---------

Signed-off-by: Udit Takkar <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
authored and GitHub committed 2023-07-31 18:51:08 +00:00
1 parent e93f1e2329
commit 12abca65b8
2 files changed
+45 -15

No files matched your search

@@ -185,11 +185,13 @@ const BackButtonInSidebar = ({ name }: { name: string }) => {
interface SettingsSidebarContainerProps {
className?: string;
navigationIsOpenedOnMobile?: boolean;
bannersHeight?: number;
}
const SettingsSidebarContainer = ({
className = "",
navigationIsOpenedOnMobile,
bannersHeight,
}: SettingsSidebarContainerProps) => {
const { t } = useLocale();
const router = useRouter();
@@ -218,6 +220,7 @@ const SettingsSidebarContainer = ({
return (
<nav
style={{ maxHeight: `calc(100vh - ${bannersHeight}px)`, top: `${bannersHeight}px` }}
className={classNames(
"no-scrollbar bg-muted fixed bottom-0 left-0 top-0 z-20 flex max-h-screen w-56 flex-col space-y-1 overflow-x-hidden overflow-y-scroll px-2 pb-3 transition-transform max-lg:z-10 lg:sticky lg:flex",
className,
@@ -473,17 +476,10 @@ export default function SettingsLayout({
hideHeadingOnMobile
{...rest}
SidebarContainer={
<>
{/* Mobile backdrop */}
{sideContainerOpen && (
<button
onClick={() => setSideContainerOpen(false)}
className="fixed left-0 top-0 z-10 h-full w-full bg-black/50">
<span className="sr-only">{t("hide_navigation")}</span>
</button>
)}
<SettingsSidebarContainer navigationIsOpenedOnMobile={sideContainerOpen} />
</>
<SidebarContainerElement
sideContainerOpen={sideContainerOpen}
setSideContainerOpen={setSideContainerOpen}
/>
}
drawerState={state}
MobileNavigationContainer={null}
@@ -502,6 +498,36 @@ export default function SettingsLayout({
);
}
const SidebarContainerElement = ({
sideContainerOpen,
bannersHeight,
setSideContainerOpen,
}: SidebarContainerElementProps) => {
const { t } = useLocale();
return (
<>
{/* Mobile backdrop */}
{sideContainerOpen && (
<button
onClick={() => setSideContainerOpen(false)}
className="fixed left-0 top-0 z-10 h-full w-full bg-black/50">
<span className="sr-only">{t("hide_navigation")}</span>
</button>
)}
<SettingsSidebarContainer
navigationIsOpenedOnMobile={sideContainerOpen}
bannersHeight={bannersHeight}
/>
</>
);
};
type SidebarContainerElementProps = {
sideContainerOpen: boolean;
bannersHeight?: number;
setSideContainerOpen: React.Dispatch<React.SetStateAction<boolean>>;
};
export const getLayout = (page: React.ReactElement) => <SettingsLayout>{page}</SettingsLayout>;
function ShellHeader() {