fix(ios): select Quick Question draft after focus
TestFlight / Build and upload (push) Successful in 1m52s
TestFlight / Build and upload (push) Successful in 1m52s
This commit is contained in:
@@ -9,6 +9,7 @@ struct SybilQuickQuestionView: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@FocusState private var promptFocused: Bool
|
||||
@State private var promptSelection: TextSelection?
|
||||
@State private var selectionAppliedForFocusRequest: Int?
|
||||
|
||||
private var hasAnswerContent: Bool {
|
||||
!viewModel.quickQuestionMessages.isEmpty || viewModel.quickQuestionError != nil
|
||||
@@ -36,9 +37,15 @@ struct SybilQuickQuestionView: View {
|
||||
guard !Task.isCancelled else {
|
||||
return
|
||||
}
|
||||
promptFocused = true
|
||||
let prompt = viewModel.quickQuestionPrompt
|
||||
promptSelection = TextSelection(range: prompt.startIndex..<prompt.endIndex)
|
||||
if promptFocused {
|
||||
selectPromptForCurrentFocusRequest()
|
||||
} else {
|
||||
promptFocused = true
|
||||
}
|
||||
}
|
||||
.onChange(of: promptFocused) { _, isFocused in
|
||||
guard isFocused else { return }
|
||||
selectPromptForCurrentFocusRequest()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +213,13 @@ struct SybilQuickQuestionView: View {
|
||||
promptFocused = false
|
||||
_ = viewModel.sendQuickQuestion()
|
||||
}
|
||||
|
||||
private func selectPromptForCurrentFocusRequest() {
|
||||
guard selectionAppliedForFocusRequest != focusRequest else { return }
|
||||
let prompt = viewModel.quickQuestionPrompt
|
||||
promptSelection = TextSelection(range: prompt.startIndex..<prompt.endIndex)
|
||||
selectionAppliedForFocusRequest = focusRequest
|
||||
}
|
||||
}
|
||||
|
||||
private struct QuickQuestionPickerPill: View {
|
||||
|
||||
Reference in New Issue
Block a user