Skip to content

Commit

Permalink
enable interaction with other components when a dropdown is open (#8432)
Browse files Browse the repository at this point in the history
  • Loading branch information
khavinshankar authored Sep 2, 2024
1 parent 93347f4 commit 43de4e7
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 26 deletions.
6 changes: 4 additions & 2 deletions src/Components/CameraFeed/AssetBedSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { AssetBedModel } from "../Assets/AssetTypes";
import {
Listbox,
ListboxButton,
ListboxOption,
ListboxOptions,
} from "@headlessui/react";

import { AssetBedModel } from "../Assets/AssetTypes";
import ButtonV2 from "../Common/components/ButtonV2";
import CareIcon from "../../CAREUI/icons/CareIcon";
import { classNames } from "../../Utils/utils";
import { dropdownOptionClassNames } from "../Form/MultiSelectMenuV2";
import ButtonV2 from "../Common/components/ButtonV2";

interface Props {
disabled?: boolean;
Expand Down Expand Up @@ -108,6 +109,7 @@ export const CameraPresetDropdown = (
</span>
</ListboxButton>
<ListboxOptions
modal={false}
as="ul"
className="absolute z-20 max-h-48 w-full overflow-auto rounded-b-lg bg-white py-1 text-base shadow-lg ring-1 ring-secondary-500 focus:outline-none md:max-h-60"
>
Expand Down
7 changes: 4 additions & 3 deletions src/Components/Common/components/Menu.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Anyone, AuthorizedElementProps } from "../../../Utils/AuthorizeFor";

import { ButtonSize, ButtonVariant } from "./ButtonV2";
import CareIcon from "../../../CAREUI/icons/CareIcon";
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/react";
import { DetailedHTMLProps, HTMLAttributes, ReactNode } from "react";
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/react";

import CareIcon from "../../../CAREUI/icons/CareIcon";
import { classNames } from "../../../Utils/utils";
import { useIsAuthorized } from "../../../Common/hooks/useIsAuthorized";

Expand Down Expand Up @@ -51,6 +51,7 @@ export default function DropdownMenu({
</MenuButton>

<MenuItems
modal={false}
className={`absolute right-0 z-10 mt-2 min-w-full origin-top-right rounded-lg bg-white py-1 shadow-lg ring-1 ring-black/5 focus:outline-none sm:min-w-[250px] md:w-max ${props.itemClassName}`}
>
<>{props.children}</>
Expand Down
12 changes: 7 additions & 5 deletions src/Components/Form/AutoCompleteAsync.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { useEffect, useState, useMemo } from "react";
import {
Combobox,
ComboboxButton,
ComboboxInput,
ComboboxOption,
ComboboxOptions,
} from "@headlessui/react";
import { debounce } from "lodash-es";
import { DropdownTransition } from "../Common/components/HelperComponents";
import CareIcon from "../../CAREUI/icons/CareIcon";
import {
MultiSelectOptionChip,
dropdownOptionClassNames,
} from "./MultiSelectMenuV2";
import { useTranslation } from "react-i18next";
import { useEffect, useMemo, useState } from "react";

import CareIcon from "../../CAREUI/icons/CareIcon";
import { DropdownTransition } from "../Common/components/HelperComponents";
import { classNames } from "../../Utils/utils";
import { debounce } from "lodash-es";
import { useTranslation } from "react-i18next";

interface Props {
id?: string;
Expand Down Expand Up @@ -153,6 +154,7 @@ const AutoCompleteAsync = (props: Props) => {
</div>
<DropdownTransition>
<ComboboxOptions
modal={false}
as="ul"
className="cui-dropdown-base absolute top-12 z-10 text-sm"
>
Expand Down
10 changes: 6 additions & 4 deletions src/Components/Form/FormFields/Autocomplete.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { useEffect, useState } from "react";
import {
Combobox,
ComboboxButton,
ComboboxInput,
ComboboxOption,
ComboboxOptions,
} from "@headlessui/react";
import { DropdownTransition } from "../../Common/components/HelperComponents";
import CareIcon from "../../../CAREUI/icons/CareIcon";
import { dropdownOptionClassNames } from "../MultiSelectMenuV2";
import { FormFieldBaseProps, useFormFieldPropsResolver } from "./Utils";
import { useEffect, useState } from "react";

import CareIcon from "../../../CAREUI/icons/CareIcon";
import { DropdownTransition } from "../../Common/components/HelperComponents";
import FormField from "./FormField";
import { classNames } from "../../../Utils/utils";
import { dropdownOptionClassNames } from "../MultiSelectMenuV2";
import { useTranslation } from "react-i18next";

type OptionCallback<T, R> = (option: T) => R;
Expand Down Expand Up @@ -209,6 +210,7 @@ export const Autocomplete = <T, V>(props: AutocompleteProps<T, V>) => {

<DropdownTransition>
<ComboboxOptions
modal={false}
as="ul"
className="cui-dropdown-base absolute z-10 mt-0.5 origin-top-right"
>
Expand Down
16 changes: 9 additions & 7 deletions src/Components/Form/FormFields/AutocompleteMultiselect.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { FormFieldBaseProps, useFormFieldPropsResolver } from "./Utils";
import {
MultiSelectOptionChip,
dropdownOptionClassNames,
} from "../MultiSelectMenuV2";
import { ReactNode, useEffect, useRef, useState } from "react";
import CareIcon from "../../../CAREUI/icons/CareIcon";
import {
Combobox,
ComboboxButton,
ComboboxInput,
ComboboxOption,
ComboboxOptions,
} from "@headlessui/react";
import { FormFieldBaseProps, useFormFieldPropsResolver } from "./Utils";
import {
MultiSelectOptionChip,
dropdownOptionClassNames,
} from "../MultiSelectMenuV2";
import { ReactNode, useEffect, useRef, useState } from "react";

import CareIcon from "../../../CAREUI/icons/CareIcon";
import { DropdownTransition } from "../../Common/components/HelperComponents";
import FormField from "./FormField";
import { classNames } from "../../../Utils/utils";
Expand Down Expand Up @@ -176,6 +177,7 @@ export const AutocompleteMutliSelect = <T, V>(

<DropdownTransition>
<ComboboxOptions
modal={false}
as="ul"
className="cui-dropdown-base absolute top-12 z-10 mt-0.5"
>
Expand Down
6 changes: 4 additions & 2 deletions src/Components/Form/MultiSelectMenuV2.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import CareIcon from "../../CAREUI/icons/CareIcon";
import {
Label,
Listbox,
ListboxButton,
ListboxOption,
ListboxOptions,
} from "@headlessui/react";
import { classNames } from "../../Utils/utils";
import { ReactNode, useRef } from "react";

import CareIcon from "../../CAREUI/icons/CareIcon";
import { classNames } from "../../Utils/utils";

type OptionCallback<T, R = void> = (option: T) => R;

type Props<T, V = T> = {
Expand Down Expand Up @@ -135,6 +136,7 @@ const MultiSelectMenuV2 = <T, V>(props: Props<T, V>) => {
</ListboxButton>
</div>
<ListboxOptions
modal={false}
as="ul"
className="cui-dropdown-base absolute top-full"
>
Expand Down
11 changes: 8 additions & 3 deletions src/Components/Form/SelectMenuV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import {
ListboxOption,
ListboxOptions,
} from "@headlessui/react";

import CareIcon from "../../CAREUI/icons/CareIcon";
import { dropdownOptionClassNames } from "./MultiSelectMenuV2";
import { classNames } from "../../Utils/utils";
import { ReactNode } from "react";
import { classNames } from "../../Utils/utils";
import { dropdownOptionClassNames } from "./MultiSelectMenuV2";

type OptionCallback<T, R> = (option: T) => R;

Expand Down Expand Up @@ -131,7 +132,11 @@ const SelectMenuV2 = <T, V>(props: SelectMenuProps<T, V>) => {
props.position === "above" ? "bottom-0 mb-12" : "top-0 mt-12",
)}
>
<ListboxOptions as="ul" className="cui-dropdown-base">
<ListboxOptions
modal={false}
as="ul"
className="cui-dropdown-base"
>
{options.map((option, index) => (
<ListboxOption
as="li"
Expand Down

0 comments on commit 43de4e7

Please sign in to comment.