Skip to content

Commit 57398e0

Browse files
committed
chore: Follow up for the modal root fixes
1 parent 855ea03 commit 57398e0

File tree

3 files changed

+49
-27
lines changed

3 files changed

+49
-27
lines changed

pages/modal/async-modal-root.page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import React, { useState } from 'react';
44

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

7-
const getModalRoot: ModalProps['getModalRoot'] = async () => {
7+
const getModalRoot: ModalProps['getModalRoot'] = async ({ abortSignal }) => {
88
await new Promise(resolve => setTimeout(resolve, 1000));
99
const element = document.createElement('div');
1010
element.setAttribute('id', 'async-modal-root');
11-
document.body.appendChild(element);
11+
if (!abortSignal.aborted) {
12+
document.body.appendChild(element);
13+
}
1214
return element;
1315
};
1416

src/__tests__/snapshot-tests/__snapshots__/documenter.test.ts.snap

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7646,14 +7646,19 @@ is provided by its parent form field component.",
76467646
"description": "Use this property to specify a different dynamic modal root for the dialog.
76477647
The function will be called when a user clicks on the trigger button.",
76487648
"inlineType": {
7649-
"name": "() => Promise<HTMLElement>",
7650-
"parameters": [],
7649+
"name": "(options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>",
7650+
"parameters": [
7651+
{
7652+
"name": "options",
7653+
"type": "{ abortSignal: AbortSignal; }",
7654+
},
7655+
],
76517656
"returnType": "Promise<HTMLElement>",
76527657
"type": "function",
76537658
},
76547659
"name": "getModalRoot",
76557660
"optional": true,
7656-
"type": "(() => Promise<HTMLElement>)",
7661+
"type": "((options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>)",
76577662
},
76587663
{
76597664
"description": "An object containing all the necessary localized strings required by the component.
@@ -8088,19 +8093,19 @@ You can use any theme provided by Ace.",
80888093
element after a user closes the dialog. The function receives the return value
80898094
of the most recent getModalRoot call as an argument.",
80908095
"inlineType": {
8091-
"name": "(container: HTMLElement) => void",
8096+
"name": "(container: HTMLElement | null) => void",
80928097
"parameters": [
80938098
{
80948099
"name": "container",
8095-
"type": "HTMLElement",
8100+
"type": "HTMLElement | null",
80968101
},
80978102
],
80988103
"returnType": "void",
80998104
"type": "function",
81008105
},
81018106
"name": "removeModalRoot",
81028107
"optional": true,
8103-
"type": "((container: HTMLElement) => void)",
8108+
"type": "((container: HTMLElement | null) => void)",
81048109
},
81058110
{
81068111
"description": "List of Ace themes available for selection in preferences dialog. Make sure you include at least one light and at
@@ -8544,14 +8549,19 @@ the custom content is displayed at the bottom of the left column within the moda
85448549
"description": "Use this property to specify a different dynamic modal root for the dialog.
85458550
The function will be called when a user clicks on the trigger button.",
85468551
"inlineType": {
8547-
"name": "() => Promise<HTMLElement>",
8548-
"parameters": [],
8552+
"name": "(options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>",
8553+
"parameters": [
8554+
{
8555+
"name": "options",
8556+
"type": "{ abortSignal: AbortSignal; }",
8557+
},
8558+
],
85498559
"returnType": "Promise<HTMLElement>",
85508560
"type": "function",
85518561
},
85528562
"name": "getModalRoot",
85538563
"optional": true,
8554-
"type": "(() => Promise<HTMLElement>)",
8564+
"type": "((options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>)",
85558565
},
85568566
{
85578567
"deprecatedTag": "The usage of the \`id\` attribute is reserved for internal use cases. For testing and other use cases,
@@ -8691,19 +8701,19 @@ It contains the following:
86918701
element after a user closes the dialog. The function receives the return value
86928702
of the most recent getModalRoot call as an argument.",
86938703
"inlineType": {
8694-
"name": "(container: HTMLElement) => void",
8704+
"name": "(container: HTMLElement | null) => void",
86958705
"parameters": [
86968706
{
86978707
"name": "container",
8698-
"type": "HTMLElement",
8708+
"type": "HTMLElement | null",
86998709
},
87008710
],
87018711
"returnType": "void",
87028712
"type": "function",
87038713
},
87048714
"name": "removeModalRoot",
87058715
"optional": true,
8706-
"type": "((container: HTMLElement) => void)",
8716+
"type": "((container: HTMLElement | null) => void)",
87078717
},
87088718
{
87098719
"description": "Configures the sticky columns preference that can be set for both left and right columns.
@@ -16765,14 +16775,19 @@ The event detail contains the \`reason\`, which can be any of the following:
1676516775
"description": "Use this property to specify a different dynamic modal root for the dialog.
1676616776
The function will be called when a user clicks on the trigger button.",
1676716777
"inlineType": {
16768-
"name": "() => Promise<HTMLElement>",
16769-
"parameters": [],
16778+
"name": "(options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>",
16779+
"parameters": [
16780+
{
16781+
"name": "options",
16782+
"type": "{ abortSignal: AbortSignal; }",
16783+
},
16784+
],
1677016785
"returnType": "Promise<HTMLElement>",
1677116786
"type": "function",
1677216787
},
1677316788
"name": "getModalRoot",
1677416789
"optional": true,
16775-
"type": "(() => Promise<HTMLElement>)",
16790+
"type": "((options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>)",
1677616791
},
1677716792
{
1677816793
"deprecatedTag": "The usage of the \`id\` attribute is reserved for internal use cases. For testing and other use cases,
@@ -16796,19 +16811,19 @@ render to an element under \`document.body\`.",
1679616811
element after a user closes the dialog. The function receives the return value
1679716812
of the most recent getModalRoot call as an argument.",
1679816813
"inlineType": {
16799-
"name": "(container: HTMLElement) => void",
16814+
"name": "(container: HTMLElement | null) => void",
1680016815
"parameters": [
1680116816
{
1680216817
"name": "container",
16803-
"type": "HTMLElement",
16818+
"type": "HTMLElement | null",
1680416819
},
1680516820
],
1680616821
"returnType": "void",
1680716822
"type": "function",
1680816823
},
1680916824
"name": "removeModalRoot",
1681016825
"optional": true,
16811-
"type": "((container: HTMLElement) => void)",
16826+
"type": "((container: HTMLElement | null) => void)",
1681216827
},
1681316828
{
1681416829
"defaultValue": "'medium'",
@@ -20424,14 +20439,19 @@ The return type of the function should be a promise that resolves to a list of v
2042420439
"description": "Use this property to specify a different dynamic modal root for the dialog.
2042520440
The function will be called when a user clicks on the trigger button.",
2042620441
"inlineType": {
20427-
"name": "() => Promise<HTMLElement>",
20428-
"parameters": [],
20442+
"name": "(options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>",
20443+
"parameters": [
20444+
{
20445+
"name": "options",
20446+
"type": "{ abortSignal: AbortSignal; }",
20447+
},
20448+
],
2042920449
"returnType": "Promise<HTMLElement>",
2043020450
"type": "function",
2043120451
},
2043220452
"name": "getModalRoot",
2043320453
"optional": true,
20434-
"type": "(() => Promise<HTMLElement>)",
20454+
"type": "((options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>)",
2043520455
},
2043620456
{
2043720457
"description": "An object containing all the necessary localized strings required by the component.",
@@ -20990,19 +21010,19 @@ and 'Size'.",
2099021010
element after a user closes the dialog. The function receives the return value
2099121011
of the most recent getModalRoot call as an argument.",
2099221012
"inlineType": {
20993-
"name": "(container: HTMLElement) => void",
21013+
"name": "(container: HTMLElement | null) => void",
2099421014
"parameters": [
2099521015
{
2099621016
"name": "container",
20997-
"type": "HTMLElement",
21017+
"type": "HTMLElement | null",
2099821018
},
2099921019
],
2100021020
"returnType": "void",
2100121021
"type": "function",
2100221022
},
2100321023
"name": "removeModalRoot",
2100421024
"optional": true,
21005-
"type": "((container: HTMLElement) => void)",
21025+
"type": "((container: HTMLElement | null) => void)",
2100621026
},
2100721027
{
2100821028
"description": "The current selected resource. Resource has the following properties:

src/modal/__integ__/modal.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ test(
9898
})
9999
);
100100

101-
(process.env.REACT_VERSION !== '18' ? test : test.skip)(
101+
test(
102102
'renders modal in async root',
103103
useBrowser(async browser => {
104104
const page = new BasePageObject(browser);

0 commit comments

Comments
 (0)