stop console opening mobile keyboard

This commit is contained in:
robert dennis
2026-10-11 00:18:11 -04:00
parent 890dc0d863
commit 2aa8e5fc64
2 changed files with 17 additions and 1 deletions
@@ -39,10 +39,13 @@ vi.mock('ghostty-web', () => ({
this.renderedViewportY = viewportY;
},
};
textarea: HTMLTextAreaElement | undefined;
constructor(public options: ITerminalOptions) {
terminals.push(this);
}
open() {}
open(element: HTMLElement) {
this.textarea = element.appendChild(document.createElement('textarea'));
}
loadAddon() {}
registerLinkProvider() {}
attachCustomKeyEventHandler() {}
@@ -132,6 +135,15 @@ describe('useTerminal', () => {
expect(Object.keys(theme)).toHaveLength(22);
});
it('keeps the on-screen keyboard closed when the read-only terminal takes focus', async () => {
const { container } = render(<Harness />);
await waitFor(() => expect(container.firstElementChild).toHaveAttribute('data-ready', 'true'));
expect(container.firstElementChild).toHaveAttribute('inputmode', 'none');
expect(container.querySelector('textarea')).toHaveAttribute('inputmode', 'none');
});
it('keeps a scrolled-up viewport on the same lines when new output arrives', async () => {
const { container } = render(<Harness />);
@@ -190,7 +190,11 @@ export const useTerminal = () => {
const term = new Terminal({ ...terminalProps, ...style, ghostty });
const fit = new FitAddon();
// Ghostty focuses its editable mount on open and its hidden textarea on tap, even with
// stdin disabled; without this every server page opens the on-screen keyboard on mobile.
mount.setAttribute('inputmode', 'none');
term.open(mount);
term.textarea?.setAttribute('inputmode', 'none');
term.loadAddon(fit);
fit.fit();
fit.observeResize();