feat: clear console outputs when closing block (#676)
This commit is contained in:
parent
50bd4604b6
commit
1df0181035
1 changed files with 9 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ import {
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { ConsoleOutput } from './block';
|
import { ConsoleOutput } from './block';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
|
import { useBlockSelector } from '@/hooks/use-block';
|
||||||
|
|
||||||
interface ConsoleProps {
|
interface ConsoleProps {
|
||||||
consoleOutputs: Array<ConsoleOutput>;
|
consoleOutputs: Array<ConsoleOutput>;
|
||||||
|
|
@ -21,6 +22,8 @@ export function Console({ consoleOutputs, setConsoleOutputs }: ConsoleProps) {
|
||||||
const [isResizing, setIsResizing] = useState(false);
|
const [isResizing, setIsResizing] = useState(false);
|
||||||
const consoleEndRef = useRef<HTMLDivElement>(null);
|
const consoleEndRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
const isBlockVisible = useBlockSelector((state) => state.isVisible);
|
||||||
|
|
||||||
const minHeight = 100;
|
const minHeight = 100;
|
||||||
const maxHeight = 800;
|
const maxHeight = 800;
|
||||||
|
|
||||||
|
|
@ -57,6 +60,12 @@ export function Console({ consoleOutputs, setConsoleOutputs }: ConsoleProps) {
|
||||||
consoleEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
consoleEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
||||||
}, [consoleOutputs]);
|
}, [consoleOutputs]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isBlockVisible) {
|
||||||
|
setConsoleOutputs([]);
|
||||||
|
}
|
||||||
|
}, [isBlockVisible, setConsoleOutputs]);
|
||||||
|
|
||||||
return consoleOutputs.length > 0 ? (
|
return consoleOutputs.length > 0 ? (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue