Skip to content

Commit 4c60f2a

Browse files
committed
chore: Follow up for the modal root fixes
1 parent ed70c95 commit 4c60f2a

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'",
@@ -20434,14 +20449,19 @@ The return type of the function should be a promise that resolves to a list of v
2043420449
"description": "Use this property to specify a different dynamic modal root for the dialog.
2043520450
The function will be called when a user clicks on the trigger button.",
2043620451
"inlineType": {
20437-
"name": "() => Promise<HTMLElement>",
20438-
"parameters": [],
20452+
"name": "(options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>",
20453+
"parameters": [
20454+
{
20455+
"name": "options",
20456+
"type": "{ abortSignal: AbortSignal; }",
20457+
},
20458+
],
2043920459
"returnType": "Promise<HTMLElement>",
2044020460
"type": "function",
2044120461
},
2044220462
"name": "getModalRoot",
2044320463
"optional": true,
20444-
"type": "(() => Promise<HTMLElement>)",
20464+
"type": "((options: { abortSignal: AbortSignal; }) => Promise<HTMLElement>)",
2044520465
},
2044620466
{
2044720467
"description": "An object containing all the necessary localized strings required by the component.",
@@ -21000,19 +21020,19 @@ and 'Size'.",
2100021020
element after a user closes the dialog. The function receives the return value
2100121021
of the most recent getModalRoot call as an argument.",
2100221022
"inlineType": {
21003-
"name": "(container: HTMLElement) => void",
21023+
"name": "(container: HTMLElement | null) => void",
2100421024
"parameters": [
2100521025
{
2100621026
"name": "container",
21007-
"type": "HTMLElement",
21027+
"type": "HTMLElement | null",
2100821028
},
2100921029
],
2101021030
"returnType": "void",
2101121031
"type": "function",
2101221032
},
2101321033
"name": "removeModalRoot",
2101421034
"optional": true,
21015-
"type": "((container: HTMLElement) => void)",
21035+
"type": "((container: HTMLElement | null) => void)",
2101621036
},
2101721037
{
2101821038
"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)