Skip to content

Commit bd2ca0b

Browse files
authored
fix: Toast examples in iframes (#7390)
* fix: Toast examples in iframes * fix ts
1 parent 0ab0544 commit bd2ca0b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/@react-spectrum/toast/stories/Toast.stories.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,15 @@ function IframeExample() {
264264

265265
// Catch toasts inside the iframe and redirect them outside.
266266
window.addEventListener('react-spectrum-toast', (e) => {
267-
e.preventDefault();
268-
if (e instanceof CustomEvent) {
269-
ToastQueue[e.detail.variant](e.detail.children, e.detail.options);
270-
}
267+
let evt = e as CustomEvent;
268+
evt.preventDefault();
269+
ToastQueue[evt.detail.variant](evt.detail.children, evt.detail.options);
271270
});
272271

273272
let prevFocusedElement: HTMLElement | null = null;
274273
window.addEventListener('react-aria-landmark-navigation', (e) => {
275-
e.preventDefault();
274+
let evt = e as CustomEvent;
275+
evt.preventDefault();
276276
let el = document.activeElement;
277277
if (el !== document.body) {
278278
prevFocusedElement = el as HTMLElement;
@@ -283,7 +283,7 @@ function IframeExample() {
283283

284284
window.parent.postMessage({
285285
type: 'landmark-navigation',
286-
direction: e instanceof CustomEvent ? e.detail.direction : undefined
286+
direction: evt.detail.direction
287287
});
288288

289289
setTimeout(() => {

0 commit comments

Comments
 (0)