fix: set explicit container dimensions before xterm init
- Measure parent dimensions and set them on container before term.open() - Ensures FitAddon gets correct dimensions on initialization - Prevents 1-row/1-col calculation that breaks scrolling and sizing
This commit is contained in:
@@ -197,7 +197,15 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
|
||||
term.loadAddon(fitAddon);
|
||||
term.loadAddon(new WebLinksAddon());
|
||||
|
||||
term.open(terminalRef.current);
|
||||
// Ensure container has explicit dimensions before xterm initializes
|
||||
const container = terminalRef.current;
|
||||
const parentRect = container.parentElement?.getBoundingClientRect();
|
||||
if (parentRect) {
|
||||
container.style.width = `${parentRect.width}px`;
|
||||
container.style.height = `${parentRect.height}px`;
|
||||
}
|
||||
|
||||
term.open(container);
|
||||
|
||||
// Connect WebSocket
|
||||
const ws = connectWebSocket();
|
||||
|
||||
Reference in New Issue
Block a user