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

fix(Tearsheet): address Element type issue with portalTarget prop type #3621

Merged
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
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
Loading