Skip to content

Commit

Permalink
Fix serial re-init required when switching tabs (#1163)
Browse files Browse the repository at this point in the history
This moves the ref for the parent container into the useEffect call
instead of copying it outside of the useEffect.
  • Loading branch information
microbit-robert authored Apr 4, 2024
1 parent 6844eba commit fe1b315
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/serial/XTerm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const useManagedTermimal = (
tabOutRef: HTMLElement,
fontSizePt: number
): void => {
const parent = ref.current;
const actionFeedback = useActionFeedback();
const codeFontFamily = useToken("fonts", "code");
const device = useDevice();
Expand All @@ -58,6 +57,7 @@ const useManagedTermimal = (
const initialFontSizeRef = useRef<number>(fontSizePt);

useEffect(() => {
const parent = ref.current;
if (!parent) {
return;
}
Expand Down Expand Up @@ -188,11 +188,11 @@ const useManagedTermimal = (
currentTerminalRef,
device,
isUnmounted,
parent,
setSelection,
fitAddon,
initialFontSizeRef,
tabOutRef,
ref,
]);

useEffect(() => {
Expand Down

0 comments on commit fe1b315

Please sign in to comment.