Skip to content

Commit 711ea7a

Browse files
committed
fix(#2288): added unique id to the root bottom sheet modal portal
1 parent d39af5e commit 711ea7a

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/components/bottomSheetModal/BottomSheetModal.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ function BottomSheetModalComponent<T = any>(
6868

6969
//#region hooks
7070
const {
71+
hostName,
7172
containerHeight,
7273
containerOffset,
7374
mountSheet,
@@ -437,6 +438,7 @@ function BottomSheetModalComponent<T = any>(
437438
<Portal
438439
key={key}
439440
name={key}
441+
hostName={hostName}
440442
handleOnMount={handlePortalRender}
441443
handleOnUpdate={handlePortalRender}
442444
handleOnUnmount={handlePortalOnUnmount}

src/components/bottomSheetModalProvider/BottomSheetModalProvider.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
BottomSheetModalInternalProvider,
77
BottomSheetModalProvider,
88
} from '../../contexts';
9+
import { id } from '../../utilities/id';
910
import {
1011
INITIAL_CONTAINER_HEIGHT,
1112
INITIAL_CONTAINER_OFFSET,
@@ -29,6 +30,7 @@ const BottomSheetModalProviderWrapper = ({
2930
//#endregion
3031

3132
//#region variables
33+
const hostName = useMemo(() => `bottom-sheet-portal-${id()}`, []);
3234
const sheetsQueueRef = useRef<BottomSheetModalRef[]>([]);
3335
//#endregion
3436

@@ -175,13 +177,15 @@ const BottomSheetModalProviderWrapper = ({
175177
);
176178
const internalContextVariables = useMemo(
177179
() => ({
180+
hostName,
178181
containerHeight: animatedContainerHeight,
179182
containerOffset: animatedContainerOffset,
180183
mountSheet: handleMountSheet,
181184
unmountSheet: handleUnmountSheet,
182185
willUnmountSheet: handleWillUnmountSheet,
183186
}),
184187
[
188+
hostName,
185189
animatedContainerHeight,
186190
animatedContainerOffset,
187191
handleMountSheet,
@@ -199,7 +203,7 @@ const BottomSheetModalProviderWrapper = ({
199203
containerOffset={animatedContainerOffset}
200204
containerHeight={animatedContainerHeight}
201205
/>
202-
<PortalProvider>{children}</PortalProvider>
206+
<PortalProvider rootHostName={hostName}>{children}</PortalProvider>
203207
</BottomSheetModalInternalProvider>
204208
</BottomSheetModalProvider>
205209
);

src/contexts/modal/internal.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
} from '../../components/bottomSheetModal';
88

99
export interface BottomSheetModalInternalContextType {
10+
hostName: string;
1011
containerHeight: SharedValue<number>;
1112
containerOffset: SharedValue<Required<Insets>>;
1213
mountSheet: (

0 commit comments

Comments
 (0)