diff --git a/resources/scripts/components/server/console/useTerminal.spec.tsx b/resources/scripts/components/server/console/useTerminal.spec.tsx index a97644895..2c256ad57 100644 --- a/resources/scripts/components/server/console/useTerminal.spec.tsx +++ b/resources/scripts/components/server/console/useTerminal.spec.tsx @@ -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(); + + 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(); diff --git a/resources/scripts/components/server/console/useTerminal.ts b/resources/scripts/components/server/console/useTerminal.ts index 168991d6a..24ee4f3ae 100644 --- a/resources/scripts/components/server/console/useTerminal.ts +++ b/resources/scripts/components/server/console/useTerminal.ts @@ -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();