Spaces:
Paused
Paused
Mishig
commited on
[Chat input] Blur on submit (#790)
Browse files* [Chat input] Blur on submit
* nuance
* extra comment
* focus only on desktop
src/lib/components/chat/ChatInput.svelte
CHANGED
|
@@ -22,6 +22,12 @@
|
|
| 22 |
// submit on enter
|
| 23 |
if (event.key === "Enter" && !event.shiftKey && !isCompositionOn) {
|
| 24 |
event.preventDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
dispatch("submit"); // use a custom event instead of `event.target.form.requestSubmit()` as it does not work on Safari 14
|
| 26 |
}
|
| 27 |
}
|
|
|
|
| 22 |
// submit on enter
|
| 23 |
if (event.key === "Enter" && !event.shiftKey && !isCompositionOn) {
|
| 24 |
event.preventDefault();
|
| 25 |
+
// blur to close keyboard on mobile
|
| 26 |
+
textareaElement.blur();
|
| 27 |
+
// refocus so that user on desktop can start typing without needing to reclick on textarea
|
| 28 |
+
if (innerWidth > TABLET_VIEWPORT_WIDTH) {
|
| 29 |
+
textareaElement.focus();
|
| 30 |
+
}
|
| 31 |
dispatch("submit"); // use a custom event instead of `event.target.form.requestSubmit()` as it does not work on Safari 14
|
| 32 |
}
|
| 33 |
}
|