Skip to content

Commit 0f54550

Browse files
authored
feat(mobileNavigation): added a parameter for the portal in mobile navigation (#1132)
* feat(mobileNavigation): added a parameter for the portal in mobile navigation * fix(stories): resolve conflicts * fix(mobile-navigation): fixed component logic * fix(navigation): updated props
1 parent d44994b commit 0f54550

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/navigation/components/MobileNavigation/MobileNavigation.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const MobileNavigation: React.FC<MobileNavigationProps> = ({
1616
isOpened,
1717
topItems,
1818
bottomItems,
19+
portalContainer,
1920
...props
2021
}) => {
2122
const [isMounted, setIsMounted] = React.useState(false);
@@ -27,7 +28,7 @@ export const MobileNavigation: React.FC<MobileNavigationProps> = ({
2728
}
2829

2930
return (
30-
<Portal>
31+
<Portal container={portalContainer?.current ?? undefined}>
3132
<Foldable key={topItems?.length} className={b()} isOpened={Boolean(isOpened)}>
3233
<div className={b('wrapper')}>
3334
{topItems && (

src/navigation/components/Navigation/Navigation.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@ const b = block('navigation');
1515
export interface NavigationComponentProps extends ClassNameProps {
1616
logo: ThemedNavigationLogoData;
1717
data: HeaderData;
18+
mobilePortalContainer?: React.RefObject<HTMLElement>;
1819
}
1920

20-
export const Navigation: React.FC<NavigationComponentProps> = ({data, logo, className}) => {
21+
export const Navigation: React.FC<NavigationComponentProps> = ({
22+
data,
23+
logo,
24+
className,
25+
mobilePortalContainer,
26+
}) => {
2127
const {
2228
leftItems,
2329
rightItems,
@@ -56,6 +62,7 @@ export const Navigation: React.FC<NavigationComponentProps> = ({data, logo, clas
5662
isOpened={isSidebarOpened}
5763
activeItemId={activeItemId}
5864
onActiveItemChange={onActiveItemChange}
65+
portalContainer={mobilePortalContainer}
5966
/>
6067
</OutsideClick>
6168
</nav>

src/navigation/models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export interface MobileNavigationProps extends ClassNameProps, ActiveItemProps {
7373
isOpened?: boolean;
7474
topItems?: NavigationItemModel[];
7575
bottomItems?: NavigationItemModel[];
76+
portalContainer?: React.RefObject<HTMLElement>;
7677
}
7778

7879
export interface NavigationProps extends MobileMenuButtonProps, ActiveItemProps {

0 commit comments

Comments
 (0)