Skip to content

Commit c071059

Browse files
fix(frontend): only resize share preview when parent form
1 parent 2a66c36 commit c071059

File tree

1 file changed

+9
-6
lines changed
  • packages/frontend/components/share-preview

1 file changed

+9
-6
lines changed

packages/frontend/components/share-preview/index.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const SharePreviewComponent = class extends HTMLElement {
22
connectedCallback() {
3+
this.$form = this.closest("form");
34
this.$$outputs = this.querySelectorAll("output");
45
for (const $output of this.$$outputs) {
56
this.updatePreview($output);
@@ -12,15 +13,17 @@ export const SharePreviewComponent = class extends HTMLElement {
1213
* Resize parent window to fit output preview and input form
1314
*/
1415
resizeWindow() {
15-
const { scrollWidth, scrollHeight } = this.closest("form");
16+
if (this.$form) {
17+
const { scrollWidth, scrollHeight } = this.$form;
1618

17-
const chromeWidth = window.outerWidth - window.innerWidth;
18-
const chromeHeight = window.outerHeight - window.innerHeight;
19+
const chromeWidth = window.outerWidth - window.innerWidth;
20+
const chromeHeight = window.outerHeight - window.innerHeight;
1921

20-
const width = scrollWidth + chromeWidth;
21-
const height = scrollHeight + chromeHeight;
22+
const width = scrollWidth + chromeWidth;
23+
const height = scrollHeight + chromeHeight;
2224

23-
window.resizeTo(width, height);
25+
window.resizeTo(width, height);
26+
}
2427
}
2528

2629
/**

0 commit comments

Comments
 (0)