Skip to content

Commit f2c0a1c

Browse files
authored
chore(PreviewTools): fix editStory button in PreviewTools (#1522)
Edit Playroom button in PreviewTools doesn't open the url when the Playroom is embed in an iframe
1 parent 522c305 commit f2c0a1c

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

playroom/components/index.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,18 @@ export const PreviewTools = ({
297297
}, [overrideTheme, os, skinName, forceMobile, colorScheme, forceDesktop]);
298298

299299
const editStory = () => {
300-
if (window.location.href.includes('/preview')) {
301-
window.open(window.location.href.replace('/preview', ''));
300+
try {
301+
const href =
302+
window.parent && window.parent !== window
303+
? window.parent.location.href
304+
: window.location.href;
305+
if (href.includes('/preview')) {
306+
window.open(href.replace('/preview', ''), '_blank');
307+
}
308+
} catch {
309+
if (window.location.href.includes('/preview')) {
310+
window.open(window.location.href.replace('/preview', ''));
311+
}
302312
}
303313
};
304314

playroom/preview-tools.css.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const controls = style([
2727
'::-webkit-scrollbar': {
2828
display: 'none', // Hide in Chrome/Safari
2929
},
30-
30+
background: skinVars.colors.background,
3131
gap: 8,
3232
zIndex: 2,
3333
borderBottom: `1px solid ${skinVars.colors.divider}`,

0 commit comments

Comments
 (0)