Skip to content

Commit cd0b5d7

Browse files
committed
Fix dashboard terminal content clipped at bottom
1 parent 0dd0bac commit cd0b5d7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/renderer/components/dashboard/DashboardTerminal.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,25 @@ export function DashboardTerminal({ tabId }: DashboardTerminalProps): React.Reac
2020

2121
const originalParent = termEl.parentElement
2222

23+
const origWidth = termEl.offsetWidth
24+
const origHeight = termEl.offsetHeight
25+
26+
termEl.style.width = `${origWidth}px`
27+
termEl.style.height = `${origHeight}px`
28+
2329
container.appendChild(termEl)
2430
entry.terminal.scrollToBottom()
2531

2632
const viewport = termEl.querySelector('.xterm-viewport') as HTMLElement | null
2733
const prevOverflow = viewport?.style.overflowY ?? ''
2834
if (viewport) viewport.style.overflowY = 'hidden'
2935

30-
const termWidth = termEl.offsetWidth
31-
const termHeight = termEl.offsetHeight
3236
const containerWidth = container.clientWidth
3337
const containerHeight = container.clientHeight
3438

35-
if (termWidth > 0 && termHeight > 0 && containerWidth > 0 && containerHeight > 0) {
36-
const scaleX = containerWidth / termWidth
37-
const scaleY = containerHeight / termHeight
39+
if (origWidth > 0 && origHeight > 0 && containerWidth > 0 && containerHeight > 0) {
40+
const scaleX = containerWidth / origWidth
41+
const scaleY = containerHeight / origHeight
3842
const scale = Math.min(scaleX, scaleY)
3943
termEl.style.transform = `scale(${scale})`
4044
termEl.style.transformOrigin = 'top left'
@@ -44,6 +48,8 @@ export function DashboardTerminal({ tabId }: DashboardTerminalProps): React.Reac
4448
if (viewport) viewport.style.overflowY = prevOverflow
4549
termEl.style.transform = ''
4650
termEl.style.transformOrigin = ''
51+
termEl.style.width = ''
52+
termEl.style.height = ''
4753
if (originalParent) {
4854
originalParent.appendChild(termEl)
4955
}

0 commit comments

Comments
 (0)