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
6 changes: 4 additions & 2 deletions pages/modal/async-modal-root.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import React, { useState } from 'react';

import { Button, Modal, ModalProps } from '~components';

const getModalRoot: ModalProps['getModalRoot'] = async () => {
const getModalRoot: ModalProps['getModalRoot'] = async ({ abortSignal }) => {
await new Promise(resolve => setTimeout(resolve, 1000));
const element = document.createElement('div');
element.setAttribute('id', 'async-modal-root');
document.body.appendChild(element);
if (!abortSignal.aborted) {
document.body.appendChild(element);
Copy link
Member

Choose a reason for hiding this comment

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

Can we instead avoid calling this function when it is aborted?

Copy link
Member Author

@just-boris just-boris Nov 6, 2025

Choose a reason for hiding this comment

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

How do you imagine that? This function is async it is called on the start, and there is no way to abort it after it has been already called

Copy link
Member

Choose a reason for hiding this comment

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

got it now, thanks

}
return element;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7649,14 +7649,19 @@ is provided by its parent form field component.",
"description": "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.",
"inlineType": {
"name": "() => Promise<HTMLElement>",
"parameters": [],
"name": "(options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>",
"parameters": [
{
"name": "options",
"type": "{ abortSignal: AbortSignal; }",
},
],
"returnType": "Promise<HTMLElement>",
"type": "function",
},
"name": "getModalRoot",
"optional": true,
"type": "(() => Promise<HTMLElement>)",
"type": "((options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>)",
},
{
"description": "An object containing all the necessary localized strings required by the component.
Expand Down Expand Up @@ -8091,19 +8096,19 @@ 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": "(container: HTMLElement) => void",
"name": "(container: HTMLElement | null) => void",
Copy link
Member

Choose a reason for hiding this comment

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

is this not a breaking change?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is. I already confirmed it is safe with a dry-run to live linked in the original component-toolkit CR: 7586509761

"parameters": [
{
"name": "container",
"type": "HTMLElement",
"type": "HTMLElement | null",
},
],
"returnType": "void",
"type": "function",
},
"name": "removeModalRoot",
"optional": true,
"type": "((container: HTMLElement) => void)",
"type": "((container: HTMLElement | null) => 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 @@ -8547,14 +8552,19 @@ the custom content is displayed at the bottom of the left column within the moda
"description": "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.",
"inlineType": {
"name": "() => Promise<HTMLElement>",
"parameters": [],
"name": "(options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>",
"parameters": [
{
"name": "options",
"type": "{ abortSignal: AbortSignal; }",
},
],
"returnType": "Promise<HTMLElement>",
"type": "function",
},
"name": "getModalRoot",
"optional": true,
"type": "(() => Promise<HTMLElement>)",
"type": "((options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>)",
},
{
"deprecatedTag": "The usage of the \`id\` attribute is reserved for internal use cases. For testing and other use cases,
Expand Down Expand Up @@ -8694,19 +8704,19 @@ 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": "(container: HTMLElement) => void",
"name": "(container: HTMLElement | null) => void",
"parameters": [
{
"name": "container",
"type": "HTMLElement",
"type": "HTMLElement | null",
},
],
"returnType": "void",
"type": "function",
},
"name": "removeModalRoot",
"optional": true,
"type": "((container: HTMLElement) => void)",
"type": "((container: HTMLElement | null) => void)",
},
{
"description": "Configures the sticky columns preference that can be set for both left and right columns.
Expand Down Expand Up @@ -16774,14 +16784,19 @@ The event detail contains the \`reason\`, which can be any of the following:
"description": "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.",
"inlineType": {
"name": "() => Promise<HTMLElement>",
"parameters": [],
"name": "(options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>",
"parameters": [
{
"name": "options",
"type": "{ abortSignal: AbortSignal; }",
},
],
"returnType": "Promise<HTMLElement>",
"type": "function",
},
"name": "getModalRoot",
"optional": true,
"type": "(() => Promise<HTMLElement>)",
"type": "((options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>)",
},
{
"deprecatedTag": "The usage of the \`id\` attribute is reserved for internal use cases. For testing and other use cases,
Expand All @@ -16805,19 +16820,19 @@ 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": "(container: HTMLElement) => void",
"name": "(container: HTMLElement | null) => void",
"parameters": [
{
"name": "container",
"type": "HTMLElement",
"type": "HTMLElement | null",
},
],
"returnType": "void",
"type": "function",
},
"name": "removeModalRoot",
"optional": true,
"type": "((container: HTMLElement) => void)",
"type": "((container: HTMLElement | null) => void)",
},
{
"defaultValue": "'medium'",
Expand Down Expand Up @@ -20434,14 +20449,19 @@ The return type of the function should be a promise that resolves to a list of v
"description": "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.",
"inlineType": {
"name": "() => Promise<HTMLElement>",
"parameters": [],
"name": "(options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>",
"parameters": [
{
"name": "options",
"type": "{ abortSignal: AbortSignal; }",
},
],
"returnType": "Promise<HTMLElement>",
"type": "function",
},
"name": "getModalRoot",
"optional": true,
"type": "(() => Promise<HTMLElement>)",
"type": "((options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>)",
},
{
"description": "An object containing all the necessary localized strings required by the component.",
Expand Down Expand Up @@ -21000,19 +21020,19 @@ 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": "(container: HTMLElement) => void",
"name": "(container: HTMLElement | null) => void",
"parameters": [
{
"name": "container",
"type": "HTMLElement",
"type": "HTMLElement | null",
},
],
"returnType": "void",
"type": "function",
},
"name": "removeModalRoot",
"optional": true,
"type": "((container: HTMLElement) => void)",
"type": "((container: HTMLElement | null) => void)",
},
{
"description": "The current selected resource. Resource has the following properties:
Expand Down
2 changes: 1 addition & 1 deletion src/modal/__integ__/modal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ test(
})
);

(process.env.REACT_VERSION !== '18' ? test : test.skip)(
test(
'renders modal in async root',
useBrowser(async browser => {
const page = new BasePageObject(browser);
Expand Down
Loading