fix: keep virtual keyboard open when tapping special keys

- Use onPointerDown with preventDefault() instead of onClick
- Add onKeepFocus callback to SpecialKeysStrip and SpecialKeysPanel
- Expose focusInput via onTerminalReady in TerminalComponent
- MobileTerminalWrapper passes focus callback to keep keyboard open
This commit is contained in:
Fusion
2026-05-24 11:57:55 +02:00
parent aea1ff95f6
commit 7e0df57f8c
4 changed files with 42 additions and 15 deletions
+16 -2
View File
@@ -5,6 +5,7 @@ interface SpecialKeysStripProps {
onSend: (data: string) => void;
isVisible: boolean;
onMoreClick?: () => void;
onKeepFocus?: () => void;
}
const PRIMARY_KEYS: { key: SpecialKey; label: string }[] = [
@@ -22,16 +23,29 @@ export const SpecialKeysStrip: React.FC<SpecialKeysStripProps> = ({
onSend,
isVisible,
onMoreClick,
onKeepFocus,
}) => {
const { sendKey } = useSpecialKeys({ onSend });
const handlePointerDown = (e: React.PointerEvent, key: SpecialKey) => {
e.preventDefault();
sendKey(key);
onKeepFocus?.();
};
const handleMorePointerDown = (e: React.PointerEvent) => {
e.preventDefault();
onMoreClick?.();
onKeepFocus?.();
};
return (
<div className={`special-keys-strip ${isVisible ? "visible" : "hidden"}`}>
{PRIMARY_KEYS.map(({ key, label }) => (
<button
key={key}
className="special-key-button"
onClick={() => sendKey(key)}
onPointerDown={(e) => handlePointerDown(e, key)}
type="button"
aria-label={`Send ${label}`}
>
@@ -41,7 +55,7 @@ export const SpecialKeysStrip: React.FC<SpecialKeysStripProps> = ({
{onMoreClick && (
<button
className="special-key-button special-key-more"
onClick={onMoreClick}
onPointerDown={handleMorePointerDown}
type="button"
aria-label="More special keys"
>