Skip to content

Commit

Permalink
fix: Fixed ssr error on Select and Autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
giubatt committed Jul 9, 2021
1 parent 8fffc6f commit c3b1268
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/components/Autocomplete/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import Button, { ButtonProps } from "../Button/Button"
import Popover from "../Popover/Popover"
import Tag, { TagProps } from "../Tag/Tag"
import { isBrowser } from "../../helpers/ssr"

interface CommonProps<T extends unknown> {
/** An array of button props, each one corresponds to a Button rendered at the input end. */
Expand Down Expand Up @@ -356,7 +357,7 @@ export default forwardRef(function Autocomplete<T>(
<div>
<Popover
isInteractive
appendTo={document?.body}
appendTo={isBrowser ? document?.body : undefined}
content={
<div
{...getMenuProps({}, { suppressRefError: true })}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { InputGroupContext } from "../InputGroup/Context"
import { getDataFromChildren, isArrayEqual } from "./utils"
import { SelectOption } from "./SelectOption"
import { SelectContext } from "./context"
import { isBrowser } from "../../helpers/ssr"

export type SelectValue = string | number | Record<string, unknown>
export type SelectedItems = Array<SelectValue>
Expand Down Expand Up @@ -259,7 +260,7 @@ const Select = ({

<Popover
isVisible={isOpen}
appendTo={document?.body}
appendTo={isBrowser ? document?.body : undefined}
trigger={["manual"]}
isInteractive
placement="bottom-start"
Expand Down

0 comments on commit c3b1268

Please sign in to comment.