Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EP-3941]: Add prop to Select to disable portalling #857

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/little-crabs-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@igloo-ui/select": minor
---

Added the `disablePortal` prop to disable dropdown portal, positioning options absolutely instead
9 changes: 7 additions & 2 deletions packages/Select/src/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from "react";
import cx from "classnames";
import * as React from "react";

import Dropdown from "@igloo-ui/dropdown";
import List, { type OptionType, type Option } from "@igloo-ui/list";
import List, { type Option, type OptionType } from "@igloo-ui/list";

import SelectInput from "./SelectInput";
import SelectValue from "./SelectValue";
Expand Down Expand Up @@ -55,6 +55,9 @@ export interface SelectProps {
/** Whether or not to show the icon inside the
* dropdown list if it's available */
showListIcon?: boolean;
/** Disables the component from appending the dropdown
* to the end of the body using ReactPortal */
disablePortal?: boolean;
}

const Select: React.FunctionComponent<SelectProps> = ({
Expand All @@ -72,6 +75,7 @@ const Select: React.FunctionComponent<SelectProps> = ({
options,
selectedOption,
showListIcon = true,
disablePortal = false,
...rest
}: SelectProps) => {
const results = React.useMemo(
Expand Down Expand Up @@ -290,6 +294,7 @@ const Select: React.FunctionComponent<SelectProps> = ({
className={selectDropdownClassname}
onClose={() => toggleMenu(true)}
isReferenceWidth={!autoWidth}
disablePortal={disablePortal}
isScrollable
>
<SelectInput isOpen={canShowMenu}>
Expand Down
Loading