Skip to content

Commit 94cae0e

Browse files
committed
fix(browser): keep the preview frame stable across Snapshot/Screencast
1 parent e5fb092 commit 94cae0e

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

‎packages/app/src/components/browser/snapshot-styles.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,13 @@ export const snapshotStyles = css`
106106
107107
.view-toggle button {
108108
padding: 5px 11px;
109+
min-width: 78px;
110+
text-align: center;
109111
font-size: 11px;
110112
font-weight: 600;
111113
font-family: inherit;
112114
border: none;
115+
outline: none;
113116
background: transparent;
114117
color: var(--vscode-descriptionForeground, #ccc);
115118
cursor: pointer;
@@ -145,4 +148,10 @@ export const snapshotStyles = css`
145148
line-height: 1;
146149
margin-left: 6px;
147150
}
151+
/* kept visible (greyed) in snapshot mode so the toggle cluster doesn't change
152+
width when switching modes */
153+
.video-select:disabled {
154+
opacity: 0.4;
155+
cursor: default;
156+
}
148157
`

‎packages/app/src/components/browser/snapshot.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,20 @@ export class DevtoolsBrowser extends Element {
204204
Math.min(availW / viewportWidth, availH / effectiveViewportH)
205205
)
206206

207-
this.section.style.width = `${viewportWidth * scale}px`
208-
this.section.style.height = `${effectiveViewportH * scale + headerSize.height}px`
207+
// Keep the frame at full pane size (same as screencast) so toggling
208+
// between the two modes never resizes it; the replay iframe is scaled to
209+
// fit and centred horizontally inside the stable frame.
210+
this.section.style.width = '100%'
211+
this.section.style.height = '100%'
209212

210213
// Iframe absent in screenshot/video modes — section sizing above still runs.
211214
if (this.iframe) {
212215
this.iframe.style.width = `${viewportWidth}px`
213216
this.iframe.style.height = `${viewportHeight}px`
214217
this.iframe.style.transformOrigin = '0 0'
215218
this.iframe.style.transform = `scale(${scale})`
219+
this.iframe.style.left = `${Math.max(0, (availW - viewportWidth * scale) / 2)}px`
220+
this.iframe.style.top = '0px'
216221
}
217222
})
218223
}
@@ -525,9 +530,10 @@ export class DevtoolsBrowser extends Element {
525530
>
526531
Screencast
527532
</button>
528-
${this.#videos.length > 1 && this.#viewMode === 'video'
533+
${this.#videos.length > 1
529534
? html`<select
530535
class="video-select"
536+
?disabled=${this.#viewMode !== 'video'}
531537
@change=${(e: Event) => {
532538
this.#setActiveVideo(
533539
Number((e.target as HTMLSelectElement).value)

0 commit comments

Comments
 (0)