Skip to content

Bug #94: Keyboard can't dismiss in chat #21

@lllyys

Description

@lllyys

Bug #94: Keyboard cannot be dismissed while chatting

Severity: Low

Repro

  1. Open any book → AI panel → Chat tab
  2. Tap the text input field → keyboard appears
  3. Try to dismiss the keyboard by:
    • Scrolling the message list
    • Tapping outside the input field
    • Swiping down on the keyboard

Expected

Keyboard dismisses on scroll or tap outside, matching standard iOS chat app behavior.

Actual

Keyboard stays up. The only way to dismiss is to close the entire AI panel sheet.

Root Cause

AIChatView.swift uses a basic TextField("Type a message…", text: $inputText, axis: .vertical) with minimal modifiers:

  • No .scrollDismissesKeyboard(.interactively) on the ScrollView/List
  • No @FocusState binding to programmatically dismiss
  • No keyboard toolbar with "Done" button
  • The .onSubmit { sendCurrentMessage() } only sends the message, doesn't dismiss keyboard

The AI panel is presented as a .sheet with .presentationDetents([.medium, .large]). In .medium detent, keyboard can cover most of the visible content.

Proper Fix

Add standard iOS keyboard dismissal patterns:

// On the ScrollView containing messages:
.scrollDismissesKeyboard(.interactively)

// Or add FocusState:
@FocusState private var isInputFocused: Bool

TextField(...)
    .focused($isInputFocused)

// Dismiss on tap outside:
.onTapGesture { isInputFocused = false }

// Optional: keyboard toolbar
.toolbar {
    ToolbarItemGroup(placement: .keyboard) {
        Spacer()
        Button("Done") { isInputFocused = false }
    }
}

Files

  • vreader/Views/AI/AIChatView.swift — TextField at line 162, missing dismiss modifiers
  • vreader/Views/Reader/AIReaderPanel.swift — sheet container with NavigationStack wrapper

Refs #6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions