Skip to content

Commit a9ecea3

Browse files
committed
Fix up arrow gesture triggering when text is present
1 parent 9327283 commit a9ecea3

File tree

1 file changed

+4
-11
lines changed
  • composeApp/src/commonMain/kotlin/com/hypergonial/chat/view/composables

1 file changed

+4
-11
lines changed

composeApp/src/commonMain/kotlin/com/hypergonial/chat/view/composables/ChatBar.kt

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -194,24 +194,17 @@ fun ChatBar(
194194
modifier
195195
.onPreviewKeyEvent {
196196
if (!enabled) return@onPreviewKeyEvent false
197-
198-
if (it.type == KeyEventType.KeyDown && it.key == Key.Escape) {
197+
else if (it.type == KeyEventType.KeyDown && it.key == Key.Escape) {
199198
focusManager.clearFocus()
200199
return@onPreviewKeyEvent true
201-
}
202-
203-
if (it.type == KeyEventType.KeyDown && it.key == Key.DirectionUp) {
200+
} else if (it.type == KeyEventType.KeyDown && it.key == Key.DirectionUp && value.text.isEmpty()) {
204201
onEditLastRequested?.invoke()
205202
return@onPreviewKeyEvent true
206-
}
207-
208-
if (it.isPasteGesture() && onFilesPasted != null && !clipboardManager.hasText()) {
203+
} else if (it.isPasteGesture() && onFilesPasted != null && !clipboardManager.hasText()) {
209204
onFilePasteStart?.invoke()
210205
scope.launch { clipboardManager.getFiles()?.let { files -> onFilesPasted(files) } }
211206
return@onPreviewKeyEvent true
212-
}
213-
214-
if (it.type == KeyEventType.KeyDown && (it.key == Key.Enter || it.key == Key.NumPadEnter)) {
207+
} else if (it.type == KeyEventType.KeyDown && (it.key == Key.Enter || it.key == Key.NumPadEnter)) {
215208
if (it.isShiftPressed) {
216209
// Insert a newline at cursor position
217210
val cursorPosition = value.selection.start

0 commit comments

Comments
 (0)