Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions frontend/src/components/message/PromptInput.command.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,10 @@ describe('PromptInput command submission', () => {
renderComponent()

const input = await screen.findByPlaceholderText('Send a message...')
expect(input).toHaveAttribute('autocomplete', 'off')
expect(input).toHaveAttribute('autocorrect', 'off')
expect(input).toHaveAttribute('autocapitalize', 'off')
expect(input).toHaveAttribute('spellcheck', 'false')
fireEvent.focus(input)
fireEvent.change(input, { target: { value: 'text' } })
expect(screen.getByRole('button', { name: 'bash !' })).toBeDisabled()
Expand All @@ -654,6 +658,9 @@ describe('PromptInput command submission', () => {
expect(input).toHaveValue('!')
expect(screen.getByTestId('composer-mode-badge')).toHaveTextContent('BASH')
expect(screen.getByRole('button', { name: 'cmd /' })).toBeDisabled()
expect(input).toHaveAttribute('autocorrect', 'off')
expect(input).toHaveAttribute('autocapitalize', 'off')
expect(input).toHaveAttribute('spellcheck', 'false')

fireEvent.click(screen.getByRole('button', { name: 'bash !' }))
expect(input).toHaveValue('')
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/message/PromptInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,10 @@ return (
onDragOver={handleDragOver}
onDragLeave={handleDragLeave}
onDrop={handleDrop}
autoComplete="off"
autoCorrect="off"
autoCapitalize="off"
spellCheck={false}
placeholder={
isBashMode
? "Enter bash command..."
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/lib/keyboardShortcuts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ describe('keyboardShortcuts', () => {
expect(formatShortcutEvent(new KeyboardEvent('keydown', { key: 'Shift', shiftKey: true }))).toBeNull()
})

it('ignores a key event without a key, such as one Chrome autofill dispatches', () => {
const autofillEvent = new KeyboardEvent('keydown')
Object.defineProperty(autofillEvent, 'key', { value: undefined })

expect(formatShortcutEvent(autofillEvent)).toBeNull()
})

it('returns the shared defaults with the key set', () => {
expect(Object.keys(getDefaultKeyboardShortcuts())).toEqual(Object.keys(DEFAULT_KEYBOARD_SHORTCUTS))
})
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/keyboardShortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function formatEventModifiers(e: KeyboardEvent): string {
* Formats a keydown event as a canonical shortcut string such as `Cmd+Shift+Z`, or null for a lone modifier key.
*/
export function formatShortcutEvent(e: KeyboardEvent): string | null {
if (isModifierOnlyEvent(e)) return null
if (!e.key || isModifierOnlyEvent(e)) return null
return [...eventModifiers(e), eventMainKey(e)].join('+')
}

Expand Down