Skip to content

Commit 2bff764

Browse files
Merge pull request #1582 from devtron-labs/fix/xterm-scroll
fix: restrict width of xterm to make it scrollable
2 parents 1e0fac0 + 16c927d commit 2bff764

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/components/v2/appDetails/k8Resource/nodeDetail/NodeDetailTabs/terminal/Terminal.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { CLUSTER_STATUS, SocketConnectionType } from '../../../../../../ClusterN
1010
import { TERMINAL_STATUS } from './constants'
1111
import './terminal.scss'
1212
import { TerminalViewType } from './terminal.type'
13+
import { restrictXtermAccessibilityWidth } from './terminal.utils'
1314

1415
let clusterTimeOut
1516

@@ -51,6 +52,7 @@ export default function TerminalView({
5152
}
5253
if (sessionId && terminalRef.current) {
5354
setIsReconnection(true)
55+
restrictXtermAccessibilityWidth()
5456
postInitialize(sessionId)
5557
} else {
5658
setSocketConnection(SocketConnectionType.DISCONNECTED)

src/components/v2/appDetails/k8Resource/nodeDetail/NodeDetailTabs/terminal/terminal.utils.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,15 @@ export default function terminalStripTypeData(elementData) {
320320
return null
321321
}
322322
}
323+
324+
// To fix the scrollbar issue with Xterm in edit mode, we need to restrict the width and height of the xterm-accessibility div as same as xterm-screen div
325+
// CON: In case of resize, we need to call this function again
326+
export const restrictXtermAccessibilityWidth = () => {
327+
const xtermScreen = document.querySelector('.xterm-screen') as HTMLElement
328+
const xtermAccessibility = document.querySelector('.xterm-accessibility') as HTMLElement
329+
330+
if (xtermScreen && xtermAccessibility) {
331+
xtermAccessibility.style.width = xtermScreen.clientWidth + 'px'
332+
xtermAccessibility.style.height = xtermScreen.clientHeight + 'px'
333+
}
334+
}

0 commit comments

Comments
 (0)