Skip to content

Commit

Permalink
fix: improve field focus
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriansaliou committed Nov 27, 2024
1 parent 17f25ff commit 6fb26a7
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/assemblies/inbox/InboxForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,25 @@ export default {
},

focusMessageField(): void {
// Focus on input
(this.$refs.message as typeof FormField)?.focusFieldFromParent();
const messageComponent = this.$refs.message as typeof FormField;

// Force formatting mode to write
// Notice: this is important, as the user might be previewing a message \
// when something requests to focus on the message field. We therefore \
// need to force the mode to write.
this.formattingMode = FormattingMode.Write;
// Can focus immediately?
if (this.formattingMode === FormattingMode.Write) {
// Focus on input
messageComponent?.focusFieldFromParent();
} else {
// Force formatting mode back to write
// Notice: this is important, as the user might be previewing a \
// message when something requests to focus on the message field. We \
// therefore need to force the mode to write.
this.formattingMode = FormattingMode.Write;

// Focus on input
// Notice: once message field is visible in DOM.
this.$nextTick(() => {
messageComponent?.focusFieldFromParent();
});
}
},

clearMessageField(): void {
Expand Down

0 comments on commit 6fb26a7

Please sign in to comment.