Skip to content

Commit

Permalink
fix(Modal): ensure getElement does not return null (#4544)
Browse files Browse the repository at this point in the history
* fix(Modal): ensure getElement does not return null

* change default prop

* fix snapshots
  • Loading branch information
nicolethoen committed Jul 28, 2020
1 parent 4deab01 commit 358b0e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions packages/react-core/src/components/Modal/Modal.tsx
Expand Up @@ -79,7 +79,7 @@ export class Modal extends React.Component<ModalProps, ModalState> {
onClose: () => undefined as any,
variant: 'default',
hasNoBodyWrapper: false,
appendTo: (typeof document !== 'undefined' && document.body) || null,
appendTo: () => document.body,
ouiaSafe: true
};

Expand All @@ -105,13 +105,10 @@ export class Modal extends React.Component<ModalProps, ModalState> {
};

getElement = (appendTo: HTMLElement | (() => HTMLElement)) => {
let target: HTMLElement;
if (typeof appendTo === 'function') {
target = appendTo();
} else {
target = appendTo;
return appendTo();
}
return target;
return appendTo || document.body;
};

toggleSiblingsFromScreenReaders = (hide: boolean) => {
Expand Down
Expand Up @@ -3,7 +3,7 @@
exports[`Wizard should match snapshot (auto-generated) 1`] = `
<Modal
actions={Array []}
appendTo={<body />}
appendTo={[Function]}
aria-describedby="string"
aria-label=""
aria-labelledby="string"
Expand Down

0 comments on commit 358b0e2

Please sign in to comment.