mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-05-01 11:02:56 +02:00
Refocus CLI textbox after command completion. Closes #164.
This commit is contained in:
@@ -13,6 +13,8 @@ export function ConsolePane({
|
||||
}) {
|
||||
const [input, setInput] = useState('');
|
||||
const outputRef = useRef<HTMLDivElement>(null);
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const prevLoadingRef = useRef(loading);
|
||||
|
||||
// Auto-scroll to bottom on new entries
|
||||
useEffect(() => {
|
||||
@@ -21,6 +23,14 @@ export function ConsolePane({
|
||||
}
|
||||
}, [history]);
|
||||
|
||||
// Refocus input after command completes
|
||||
useEffect(() => {
|
||||
if (prevLoadingRef.current && !loading) {
|
||||
inputRef.current?.focus();
|
||||
}
|
||||
prevLoadingRef.current = loading;
|
||||
}, [loading]);
|
||||
|
||||
const handleSubmit = useCallback(
|
||||
async (e: FormEvent) => {
|
||||
e.preventDefault();
|
||||
@@ -59,6 +69,7 @@ export function ConsolePane({
|
||||
</div>
|
||||
<form onSubmit={handleSubmit} className="flex gap-2 p-2 border-t border-border">
|
||||
<Input
|
||||
ref={inputRef}
|
||||
type="text"
|
||||
autoComplete="off"
|
||||
name="console-input"
|
||||
|
||||
Reference in New Issue
Block a user