Skip to content

Commit

Permalink
Add prop to Select to disable portalling (#857)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexasselin008 authored Jan 13, 2025
1 parent 11a6245 commit 93ad1e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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

0 comments on commit 93ad1e2

Please sign in to comment.