Skip to content

Commit 8ac1207

Browse files
authored
chore: Follow up for the modal root fixes (#4016)
1 parent 5e1e433 commit 8ac1207

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
@@ -7649,14 +7649,19 @@ is provided by its parent form field component.",
76497649
"description": "Use this property to specify a different dynamic modal root for the dialog.
76507650
The function will be called when a user clicks on the trigger button.",
76517651
"inlineType": {
7652-
"name": "() => Promise<HTMLElement>",
7653-
"parameters": [],
7652+
"name": "(options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>",
7653+
"parameters": [
7654+
{
7655+
"name": "options",
7656+
"type": "{ abortSignal: AbortSignal; }",
7657+
},
7658+
],
76547659
"returnType": "Promise<HTMLElement>",
76557660
"type": "function",
76567661
},
76577662
"name": "getModalRoot",
76587663
"optional": true,
7659-
"type": "(() => Promise<HTMLElement>)",
7664+
"type": "((options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>)",
76607665
},
76617666
{
76627667
"description": "An object containing all the necessary localized strings required by the component.
@@ -8091,19 +8096,19 @@ You can use any theme provided by Ace.",
80918096
element after a user closes the dialog. The function receives the return value
80928097
of the most recent getModalRoot call as an argument.",
80938098
"inlineType": {
8094-
"name": "(container: HTMLElement) => void",
8099+
"name": "(container: HTMLElement | null) => void",
80958100
"parameters": [
80968101
{
80978102
"name": "container",
8098-
"type": "HTMLElement",
8103+
"type": "HTMLElement | null",
80998104
},
81008105
],
81018106
"returnType": "void",
81028107
"type": "function",
81038108
},
81048109
"name": "removeModalRoot",
81058110
"optional": true,
8106-
"type": "((container: HTMLElement) => void)",
8111+
"type": "((container: HTMLElement | null) => void)",
81078112
},
81088113
{
81098114
"description": "List of Ace themes available for selection in preferences dialog. Make sure you include at least one light and at
@@ -8547,14 +8552,19 @@ the custom content is displayed at the bottom of the left column within the moda
85478552
"description": "Use this property to specify a different dynamic modal root for the dialog.
85488553
The function will be called when a user clicks on the trigger button.",
85498554
"inlineType": {
8550-
"name": "() => Promise<HTMLElement>",
8551-
"parameters": [],
8555+
"name": "(options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>",
8556+
"parameters": [
8557+
{
8558+
"name": "options",
8559+
"type": "{ abortSignal: AbortSignal; }",
8560+
},
8561+
],
85528562
"returnType": "Promise<HTMLElement>",
85538563
"type": "function",
85548564
},
85558565
"name": "getModalRoot",
85568566
"optional": true,
8557-
"type": "(() => Promise<HTMLElement>)",
8567+
"type": "((options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>)",
85588568
},
85598569
{
85608570
"deprecatedTag": "The usage of the \`id\` attribute is reserved for internal use cases. For testing and other use cases,
@@ -8694,19 +8704,19 @@ It contains the following:
86948704
element after a user closes the dialog. The function receives the return value
86958705
of the most recent getModalRoot call as an argument.",
86968706
"inlineType": {
8697-
"name": "(container: HTMLElement) => void",
8707+
"name": "(container: HTMLElement | null) => void",
86988708
"parameters": [
86998709
{
87008710
"name": "container",
8701-
"type": "HTMLElement",
8711+
"type": "HTMLElement | null",
87028712
},
87038713
],
87048714
"returnType": "void",
87058715
"type": "function",
87068716
},
87078717
"name": "removeModalRoot",
87088718
"optional": true,
8709-
"type": "((container: HTMLElement) => void)",
8719+
"type": "((container: HTMLElement | null) => void)",
87108720
},
87118721
{
87128722
"description": "Configures the sticky columns preference that can be set for both left and right columns.
@@ -16774,14 +16784,19 @@ The event detail contains the \`reason\`, which can be any of the following:
1677416784
"description": "Use this property to specify a different dynamic modal root for the dialog.
1677516785
The function will be called when a user clicks on the trigger button.",
1677616786
"inlineType": {
16777-
"name": "() => Promise<HTMLElement>",
16778-
"parameters": [],
16787+
"name": "(options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>",
16788+
"parameters": [
16789+
{
16790+
"name": "options",
16791+
"type": "{ abortSignal: AbortSignal; }",
16792+
},
16793+
],
1677916794
"returnType": "Promise<HTMLElement>",
1678016795
"type": "function",
1678116796
},
1678216797
"name": "getModalRoot",
1678316798
"optional": true,
16784-
"type": "(() => Promise<HTMLElement>)",
16799+
"type": "((options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>)",
1678516800
},
1678616801
{
1678716802
"deprecatedTag": "The usage of the \`id\` attribute is reserved for internal use cases. For testing and other use cases,
@@ -16805,19 +16820,19 @@ render to an element under \`document.body\`.",
1680516820
element after a user closes the dialog. The function receives the return value
1680616821
of the most recent getModalRoot call as an argument.",
1680716822
"inlineType": {
16808-
"name": "(container: HTMLElement) => void",
16823+
"name": "(container: HTMLElement | null) => void",
1680916824
"parameters": [
1681016825
{
1681116826
"name": "container",
16812-
"type": "HTMLElement",
16827+
"type": "HTMLElement | null",
1681316828
},
1681416829
],
1681516830
"returnType": "void",
1681616831
"type": "function",
1681716832
},
1681816833
"name": "removeModalRoot",
1681916834
"optional": true,
16820-
"type": "((container: HTMLElement) => void)",
16835+
"type": "((container: HTMLElement | null) => void)",
1682116836
},
1682216837
{
1682316838
"defaultValue": "'medium'",
@@ -20444,14 +20459,19 @@ The return type of the function should be a promise that resolves to a list of v
2044420459
"description": "Use this property to specify a different dynamic modal root for the dialog.
2044520460
The function will be called when a user clicks on the trigger button.",
2044620461
"inlineType": {
20447-
"name": "() => Promise<HTMLElement>",
20448-
"parameters": [],
20462+
"name": "(options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>",
20463+
"parameters": [
20464+
{
20465+
"name": "options",
20466+
"type": "{ abortSignal: AbortSignal; }",
20467+
},
20468+
],
2044920469
"returnType": "Promise<HTMLElement>",
2045020470
"type": "function",
2045120471
},
2045220472
"name": "getModalRoot",
2045320473
"optional": true,
20454-
"type": "(() => Promise<HTMLElement>)",
20474+
"type": "((options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>)",
2045520475
},
2045620476
{
2045720477
"description": "An object containing all the necessary localized strings required by the component.",
@@ -21010,19 +21030,19 @@ and 'Size'.",
2101021030
element after a user closes the dialog. The function receives the return value
2101121031
of the most recent getModalRoot call as an argument.",
2101221032
"inlineType": {
21013-
"name": "(container: HTMLElement) => void",
21033+
"name": "(container: HTMLElement | null) => void",
2101421034
"parameters": [
2101521035
{
2101621036
"name": "container",
21017-
"type": "HTMLElement",
21037+
"type": "HTMLElement | null",
2101821038
},
2101921039
],
2102021040
"returnType": "void",
2102121041
"type": "function",
2102221042
},
2102321043
"name": "removeModalRoot",
2102421044
"optional": true,
21025-
"type": "((container: HTMLElement) => void)",
21045+
"type": "((container: HTMLElement | null) => void)",
2102621046
},
2102721047
{
2102821048
"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)