Skip to content

Commit

Permalink
fix(Tearsheet): address Element type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewgallo committed Oct 17, 2023
1 parent 7764b5a commit 74c311c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/ibm-products/src/components/Tearsheet/Tearsheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { ActionSet } from '../ActionSet';

import { tearsheetHasCloseIcon, TearsheetShell } from './TearsheetShell';

import { portalType } from './TearsheetShell';

const componentName = 'Tearsheet';

// NOTE: the component SCSS is not imported here: it is rolled up separately.
Expand Down Expand Up @@ -206,7 +208,7 @@ Tearsheet.propTypes = {
/**
* The DOM element that the tearsheet should be rendered within. Defaults to document.body.
*/
portalTarget: PropTypes.instanceOf(Element),
portalTarget: portalType,

/**
* Specify a CSS selector that matches the DOM element that should be focused when the Modal opens
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {
tearsheetShellWideProps as blocked,
} from './TearsheetShell';

import { portalType } from './TearsheetShell';

const componentName = 'TearsheetNarrow';

// NOTE: the component SCSS is not imported here: it is rolled up separately.
Expand Down Expand Up @@ -168,7 +170,7 @@ TearsheetNarrow.propTypes = {
/**
* The DOM element that the tearsheet should be rendered within. Defaults to document.body.
*/
portalTarget: PropTypes.instanceOf(Element),
portalTarget: portalType,

/**
* The main title of the tearsheet, displayed in the header area.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ export const TearsheetShell = React.forwardRef(
// is used in preference to relying on function.name.
TearsheetShell.displayName = componentName;

export const portalType =
typeof Element === 'undefined'
? PropTypes.object
: PropTypes.instanceOf(Element);

export const deprecatedProps = {
/**
* **Deprecated**
Expand Down Expand Up @@ -478,7 +483,7 @@ TearsheetShell.propTypes = {
/**
* The DOM element that the tearsheet should be rendered within. Defaults to document.body.
*/
portalTarget: PropTypes.instanceOf(Element),
portalTarget: portalType,

/**
* Specifies the width of the tearsheet, 'narrow' or 'wide'.
Expand Down

0 comments on commit 74c311c

Please sign in to comment.