diff --git a/components/GuestsRoomsPicker/ChildSelector/ChildInfoSelector.tsx b/components/GuestsRoomsPicker/ChildSelector/ChildInfoSelector.tsx
index b39821483..a74b52200 100644
--- a/components/GuestsRoomsPicker/ChildSelector/ChildInfoSelector.tsx
+++ b/components/GuestsRoomsPicker/ChildSelector/ChildInfoSelector.tsx
@@ -98,6 +98,7 @@ export default function ChildInfoSelector({
{...register(ageFieldName, {
required: true,
})}
+ isNestedInModal={true}
/>
@@ -114,6 +115,7 @@ export default function ChildInfoSelector({
{...register(bedFieldName, {
required: true,
})}
+ isNestedInModal={true}
/>
) : null}
diff --git a/components/GuestsRoomsPicker/Form.tsx b/components/GuestsRoomsPicker/Form.tsx
index 062347761..c93d6ed71 100644
--- a/components/GuestsRoomsPicker/Form.tsx
+++ b/components/GuestsRoomsPicker/Form.tsx
@@ -21,9 +21,11 @@ import { GuestsRoom } from "@/types/components/bookingWidget/guestsRoomsPicker"
export default function GuestsRoomsPickerDialog({
rooms,
onClose,
+ isOverflowed = false,
}: {
rooms: GuestsRoom[]
onClose: () => void
+ isOverflowed?: boolean // ToDo Remove once Tooltip below is no longer required
}) {
const intl = useIntl()
const doneLabel = intl.formatMessage({ id: "Done" })
@@ -124,7 +126,7 @@ export default function GuestsRoomsPickerDialog({
{rooms.length < 4 ? (
diff --git a/components/GuestsRoomsPicker/index.tsx b/components/GuestsRoomsPicker/index.tsx
index 2ce978b39..b37d92730 100644
--- a/components/GuestsRoomsPicker/index.tsx
+++ b/components/GuestsRoomsPicker/index.tsx
@@ -1,6 +1,6 @@
"use client"
-import { useEffect, useState } from "react"
+import { useCallback, useEffect, useState } from "react"
import {
Button,
Dialog,
@@ -26,6 +26,8 @@ export default function GuestsRoomsPickerForm() {
const checkIsDesktop = useMediaQuery("(min-width: 1367px)")
const [isDesktop, setIsDesktop] = useState(true)
+ const [containerHeight, setContainerHeight] = useState(0)
+ const childCount = rooms[0] ? rooms[0].child.length : 0 // ToDo Update for multiroom later
const htmlElement =
typeof window !== "undefined" ? document.querySelector("body") : null
@@ -46,12 +48,55 @@ export default function GuestsRoomsPickerForm() {
setIsDesktop(checkIsDesktop)
}, [checkIsDesktop])
+ const updateHeight = useCallback(() => {
+ if (typeof window !== undefined) {
+ // Get available space for picker to show without going beyond screen
+ let maxHeight =
+ window.innerHeight -
+ (document.querySelector("#booking-widget")?.getBoundingClientRect()
+ .bottom ?? 0) -
+ 50
+ const innerContainerHt = document
+ .querySelector(".react-aria-Popover")
+ ?.getBoundingClientRect().height
+ if (
+ maxHeight != containerHeight &&
+ innerContainerHt &&
+ maxHeight <= innerContainerHt
+ ) {
+ setContainerHeight(maxHeight)
+ } else if (
+ containerHeight &&
+ innerContainerHt &&
+ maxHeight > innerContainerHt
+ ) {
+ setContainerHeight(0)
+ }
+ }
+ }, [containerHeight])
+
+ useEffect(() => {
+ if (typeof window !== undefined && isDesktop) {
+ updateHeight()
+ }
+ }, [childCount, isDesktop, updateHeight])
+
return isDesktop ? (
-
+
diff --git a/components/TempDesignSystem/Popover/index.tsx b/components/TempDesignSystem/Popover/index.tsx
index b1b03f340..9d0eb3d29 100644
--- a/components/TempDesignSystem/Popover/index.tsx
+++ b/components/TempDesignSystem/Popover/index.tsx
@@ -17,9 +17,10 @@ import styles from "./popover.module.css"
export default function Popover({
triggerContent,
children,
+ isNestedPopover = false,
...props
}: PopoverProps) {
- const setOverflowVisible = useSetOverFlowVisibleOnRA()
+ const setOverflowVisible = useSetOverFlowVisibleOnRA(isNestedPopover)
return (
diff --git a/components/TempDesignSystem/Popover/popover.ts b/components/TempDesignSystem/Popover/popover.ts
index c774ca398..140f70c79 100644
--- a/components/TempDesignSystem/Popover/popover.ts
+++ b/components/TempDesignSystem/Popover/popover.ts
@@ -3,4 +3,5 @@ import type { PopoverProps as RAPopoverProps } from "react-aria-components"
export interface PopoverProps extends Omit {
triggerContent: React.ReactNode
children: React.ReactNode
+ isNestedPopover?: boolean
}
diff --git a/components/TempDesignSystem/Select/index.tsx b/components/TempDesignSystem/Select/index.tsx
index 816d8ddb9..8226d1804 100644
--- a/components/TempDesignSystem/Select/index.tsx
+++ b/components/TempDesignSystem/Select/index.tsx
@@ -38,9 +38,10 @@ export default function Select({
maxHeight,
showRadioButton = false,
discreet = false,
+ isNestedInModal = false,
}: SelectProps) {
const [rootDiv, setRootDiv] = useState(undefined)
- const setOverflowVisible = useSetOverflowVisibleOnRA()
+ const setOverflowVisible = useSetOverflowVisibleOnRA(isNestedInModal)
function setRef(node: SelectPortalContainerArgs) {
if (node) {
diff --git a/components/TempDesignSystem/Select/select.ts b/components/TempDesignSystem/Select/select.ts
index 942223277..dd2679587 100644
--- a/components/TempDesignSystem/Select/select.ts
+++ b/components/TempDesignSystem/Select/select.ts
@@ -12,6 +12,7 @@ export interface SelectProps
maxHeight?: number
showRadioButton?: boolean
discreet?: boolean
+ isNestedInModal?: boolean
}
export type SelectPortalContainer = HTMLDivElement | undefined
diff --git a/hooks/useSetOverflowVisibleOnRA.ts b/hooks/useSetOverflowVisibleOnRA.ts
index e9031b477..793974cfb 100644
--- a/hooks/useSetOverflowVisibleOnRA.ts
+++ b/hooks/useSetOverflowVisibleOnRA.ts
@@ -1,8 +1,8 @@
-export default function useSetOverflowVisibleOnRA() {
+export default function useSetOverflowVisibleOnRA(isNestedInModal: boolean) {
function setOverflowVisible(isOpen: boolean) {
if (isOpen) {
document.body.style.overflow = "visible"
- } else {
+ } else if (!isNestedInModal) {
document.body.style.overflow = ""
}
}