Fix fit addon not resizing with "more" on keyboard
This commit is contained in:
@@ -1,17 +1,25 @@
|
||||
import React, {useState, useCallback} from "react";
|
||||
import React, {useState, useCallback, useEffect} from "react";
|
||||
import Keyboard from "react-simple-keyboard";
|
||||
import "react-simple-keyboard/build/css/index.css";
|
||||
import "./kb-dark-theme.css";
|
||||
|
||||
interface TerminalKeyboardProps {
|
||||
onSendInput: (input: string) => void;
|
||||
onLayoutChange: () => void;
|
||||
}
|
||||
|
||||
export function TerminalKeyboard({onSendInput}: TerminalKeyboardProps) {
|
||||
export function TerminalKeyboard({onSendInput, onLayoutChange}: TerminalKeyboardProps) {
|
||||
const [layoutName, setLayoutName] = useState("default");
|
||||
const [isCtrl, setIsCtrl] = useState(false);
|
||||
const [isAlt, setIsAlt] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (onLayoutChange) {
|
||||
const timeoutId = setTimeout(() => onLayoutChange(), 100);
|
||||
return () => clearTimeout(timeoutId);
|
||||
}
|
||||
}, [layoutName, onLayoutChange]);
|
||||
|
||||
const onKeyPress = useCallback((button: string) => {
|
||||
if (button === "{shift}") {
|
||||
setLayoutName("shift");
|
||||
|
||||
@@ -95,6 +95,10 @@ const AppContent: FC = () => {
|
||||
|
||||
const closeSidebar = () => setIsSidebarOpen(false);
|
||||
|
||||
const handleKeyboardLayoutChange = () => {
|
||||
fitCurrentTerminal();
|
||||
}
|
||||
|
||||
function handleKeyboardInput(input: string) {
|
||||
const currentTerminalTab = getTab(currentTab as number);
|
||||
if (currentTerminalTab && currentTerminalTab.terminalRef?.current?.sendInput) {
|
||||
@@ -162,7 +166,7 @@ const AppContent: FC = () => {
|
||||
</div>
|
||||
{currentTab &&
|
||||
<div className="mb-1 z-10">
|
||||
<TerminalKeyboard onSendInput={handleKeyboardInput}/>
|
||||
<TerminalKeyboard onSendInput={handleKeyboardInput} onLayoutChange={handleKeyboardLayoutChange}/>
|
||||
</div>
|
||||
}
|
||||
<BottomNavbar
|
||||
|
||||
Reference in New Issue
Block a user