Skip to content

Commit cc3c2ce

Browse files
committed
async load the Dialog.css module
1 parent b8ed78a commit cc3c2ce

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

packages/feedback-async/src/widget/Dialog.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { DialogContent } from './components/DialogContent';
88
import type { Props as DialogContentProps } from './components/DialogContent';
99

1010
export { showSuccessMessage } from './Message';
11+
export { createDialogStyles } from './Dialog.css';
1112

1213
function renderDialog(parent: HTMLElement, props: DialogContentProps): void {
1314
render(<DialogContent {...props} />, parent);

packages/feedback-async/src/widget/DialogWithScreenShots.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { Props as DialogContentProps } from './components/DialogContent';
99
import { ScreenShotArea } from './components/ScreenShotArea';
1010

1111
export { showSuccessMessage } from './Message';
12+
export { createDialogStyles } from './Dialog.css';
1213

1314
function renderDialog(parent: HTMLElement, props: DialogContentProps): void {
1415
render(

packages/feedback-async/src/widget/createShadowHost.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { logger } from '@sentry/utils';
22

33
import { WINDOW } from '../constants';
44
import type { FeedbackInternalOptions } from '../types';
5-
import { createDialogStyles } from './Dialog.css';
65
import { createMainStyles } from './Main.css';
76

87
type CreateShadowHostParams = Pick<FeedbackInternalOptions, 'id' | 'colorScheme' | 'themeDark' | 'themeLight'>;
@@ -25,7 +24,6 @@ export function createShadowHost({ id, colorScheme, themeDark, themeLight }: Cre
2524
const shadow = host.attachShadow({ mode: 'open' });
2625

2726
shadow.appendChild(createMainStyles(doc, colorScheme, { dark: themeDark, light: themeLight }));
28-
shadow.appendChild(createDialogStyles(doc));
2927

3028
return { shadow, host };
3129
} catch {

packages/feedback-async/src/widget/createWidget.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { getCurrentScope } from '@sentry/core';
22
import { logger } from '@sentry/utils';
3-
4-
import { getMissingFields } from 'src/util/validate';
3+
import { WINDOW } from '../constants';
54
import { FEEDBACK_WIDGET_SOURCE } from '../constants';
65
import { DEBUG_BUILD } from '../debug-build';
76
import { sendFeedback } from '../sendFeedback';
87
import type { DialogComponent, FeedbackFormData, FeedbackInternalOptions, FeedbackWidget } from '../types';
8+
import { getMissingFields } from '../util/validate';
99
import type { ActorComponent } from './Actor';
1010
import { Actor } from './Actor';
1111
import { loadDialog } from './loadDialog';
@@ -40,6 +40,8 @@ export function createWidget({
4040
options: { shouldCreateActor = true, ...options },
4141
attachTo,
4242
}: CreateWidgetParams): FeedbackWidget {
43+
const doc = WINDOW.document;
44+
4345
let actor: ActorComponent | undefined;
4446
let dialog: DialogComponent | undefined;
4547

@@ -83,7 +85,7 @@ export function createWidget({
8385
const user = scope && scope.getUser();
8486

8587
loadDialog({ screenshots: false })
86-
.then(({ Dialog, showSuccessMessage }) => {
88+
.then(({ Dialog, showSuccessMessage, createDialogStyles }) => {
8789
dialog = Dialog({
8890
colorScheme: options.colorScheme,
8991
showBranding: options.showBranding,
@@ -142,6 +144,7 @@ export function createWidget({
142144
}
143145

144146
shadow.appendChild(dialog.el);
147+
shadow.appendChild(createDialogStyles(doc));
145148

146149
// Hides the default actor whenever dialog is opened
147150
hideActor();
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { DialogComponent } from '../types';
2+
import type { createDialogStyles } from './Dialog.css';
23
import type { Props as BaseProps } from './DialogBase';
34
import type { showSuccessMessage } from './Message';
45

@@ -7,17 +8,18 @@ type DialogRenderer = (props: Omit<BaseProps, 'renderDialog'>) => DialogComponen
78
type Return = {
89
Dialog: DialogRenderer;
910
showSuccessMessage: typeof showSuccessMessage;
11+
createDialogStyles: typeof createDialogStyles;
1012
};
1113

1214
/**
1315
* Async load the Dialog component for rendering.
1416
*/
1517
export async function loadDialog({ screenshots }: { screenshots: boolean }): Promise<Return> {
1618
if (screenshots) {
17-
const { Dialog, showSuccessMessage } = await import('./DialogWithScreenShots');
18-
return { Dialog, showSuccessMessage };
19+
const { Dialog, ...rest } = await import('./DialogWithScreenShots');
20+
return { Dialog, ...rest };
1921
} else {
20-
const { Dialog, showSuccessMessage } = await import('./Dialog');
21-
return { Dialog, showSuccessMessage };
22+
const { Dialog, ...rest } = await import('./Dialog');
23+
return { Dialog, ...rest };
2224
}
2325
}

0 commit comments

Comments
 (0)