Skip to content

Commit 350125b

Browse files
committed
fix: restrict width of xterm to make it scrollable
1 parent f7a244f commit 350125b

File tree

1 file changed

+13
-0
lines changed
  • src/components/v2/appDetails/k8Resource/nodeDetail/NodeDetailTabs/terminal

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ export default function TerminalView({
4343

4444
const [myDivRef] = useHeightObserver(resizeSocket)
4545

46+
// 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
47+
// CON: In case of resize, we need to call this function again
48+
const restrictXtermAccessibilityWidth = () => {
49+
const xtermScreen = document.querySelector('.xterm-screen') as HTMLElement
50+
const xtermAccessibility = document.querySelector('.xterm-accessibility') as HTMLElement
51+
52+
if (xtermScreen && xtermAccessibility) {
53+
xtermAccessibility.style.width = xtermScreen.clientWidth + 'px'
54+
xtermAccessibility.style.height = xtermScreen.clientHeight + 'px'
55+
}
56+
}
57+
4658
useEffect(() => {
4759
if (!terminalRef.current) {
4860
elementDidMount('#terminal-id').then(() => {
@@ -51,6 +63,7 @@ export default function TerminalView({
5163
}
5264
if (sessionId && terminalRef.current) {
5365
setIsReconnection(true)
66+
restrictXtermAccessibilityWidth()
5467
postInitialize(sessionId)
5568
} else {
5669
setSocketConnection(SocketConnectionType.DISCONNECTED)

0 commit comments

Comments
 (0)