Skip to content
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
4 changes: 3 additions & 1 deletion pages/modal/async-modal-root.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const getModalRoot: ModalProps['getModalRoot'] = async () => {
};

const removeModalRoot: ModalProps['removeModalRoot'] = root => {
document.body.removeChild(root);
if (root) {
document.body.removeChild(root);
}
};

export default function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8088,10 +8088,10 @@ You can use any theme provided by Ace.",
element after a user closes the dialog. The function receives the return value
of the most recent getModalRoot call as an argument.",
"inlineType": {
"name": "(rootElement: HTMLElement) => void",
"name": "(container: HTMLElement) => void",
"parameters": [
{
"name": "rootElement",
"name": "container",
"type": "HTMLElement",
},
],
Expand All @@ -8100,7 +8100,7 @@ of the most recent getModalRoot call as an argument.",
},
"name": "removeModalRoot",
"optional": true,
"type": "((rootElement: HTMLElement) => void)",
"type": "((container: HTMLElement) => void)",
},
{
"description": "List of Ace themes available for selection in preferences dialog. Make sure you include at least one light and at
Expand Down Expand Up @@ -8691,10 +8691,10 @@ It contains the following:
element after a user closes the dialog. The function receives the return value
of the most recent getModalRoot call as an argument.",
"inlineType": {
"name": "(rootElement: HTMLElement) => void",
"name": "(container: HTMLElement) => void",
"parameters": [
{
"name": "rootElement",
"name": "container",
"type": "HTMLElement",
},
],
Expand All @@ -8703,7 +8703,7 @@ of the most recent getModalRoot call as an argument.",
},
"name": "removeModalRoot",
"optional": true,
"type": "((rootElement: HTMLElement) => void)",
"type": "((container: HTMLElement) => void)",
},
{
"description": "Configures the sticky columns preference that can be set for both left and right columns.
Expand Down Expand Up @@ -16796,10 +16796,10 @@ render to an element under \`document.body\`.",
element after a user closes the dialog. The function receives the return value
of the most recent getModalRoot call as an argument.",
"inlineType": {
"name": "(rootElement: HTMLElement) => void",
"name": "(container: HTMLElement) => void",
"parameters": [
{
"name": "rootElement",
"name": "container",
"type": "HTMLElement",
},
],
Expand All @@ -16808,7 +16808,7 @@ of the most recent getModalRoot call as an argument.",
},
"name": "removeModalRoot",
"optional": true,
"type": "((rootElement: HTMLElement) => void)",
"type": "((container: HTMLElement) => void)",
},
{
"defaultValue": "'medium'",
Expand Down Expand Up @@ -20990,10 +20990,10 @@ and 'Size'.",
element after a user closes the dialog. The function receives the return value
of the most recent getModalRoot call as an argument.",
"inlineType": {
"name": "(rootElement: HTMLElement) => void",
"name": "(container: HTMLElement) => void",
"parameters": [
{
"name": "rootElement",
"name": "container",
"type": "HTMLElement",
},
],
Expand All @@ -21002,7 +21002,7 @@ of the most recent getModalRoot call as an argument.",
},
"name": "removeModalRoot",
"optional": true,
"type": "((rootElement: HTMLElement) => void)",
"type": "((container: HTMLElement) => void)",
},
{
"description": "The current selected resource. Resource has the following properties:
Expand Down
6 changes: 4 additions & 2 deletions src/modal/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
import React from 'react';

import { PortalProps } from '@cloudscape-design/component-toolkit/internal';

import { FlowType } from '../internal/analytics/interfaces';
import { BaseComponentProps } from '../internal/base-component';
import { NonCancelableEventHandler } from '../internal/events';
Expand All @@ -11,14 +13,14 @@ export interface BaseModalProps {
* Use this property to specify a different dynamic modal root for the dialog.
* The function will be called when a user clicks on the trigger button.
*/
getModalRoot?: () => Promise<HTMLElement>;
getModalRoot?: PortalProps['getContainer'];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signature of this function will change. Replacing the manual signature with a type reference to mirror the signature from the upstream without copying


/**
* Use this property when `getModalRoot` is used to clean up the modal root
* element after a user closes the dialog. The function receives the return value
* of the most recent getModalRoot call as an argument.
*/
removeModalRoot?: (rootElement: HTMLElement) => void;
removeModalRoot?: PortalProps['removeContainer'];
}

export interface ModalProps extends BaseComponentProps, BaseModalProps {
Expand Down
Loading