Skip to content

Commit 468a226

Browse files
committed
(props) add textarea-auto-focus
1 parent a2ce073 commit 468a226

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ fetchMessages({ room, options }) {
246246
| `link-options`(19) | Object | - | `{ disabled: false, target: '_blank', rel: null }` |
247247
| `room-info-enabled` (20) | Boolean | - | `false` |
248248
| `textarea-action-enabled`(21) | Boolean | - | `false` |
249+
| `textarea-auto-focus` | Boolean | - | `true` |
249250
| `user-tags-enabled` | Boolean | - | `true` |
250251
| `emojis-suggestion-enabled` | Boolean | - | `true` |
251252
| `media-preview-enabled` | Boolean | - | `true` |

src/lib/ChatWindow.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
:loading-rooms="loadingRooms"
5959
:room-info-enabled="roomInfoEnabled"
6060
:textarea-action-enabled="textareaActionEnabled"
61+
:textarea-auto-focus="textareaAutoFocus"
6162
:user-tags-enabled="userTagsEnabled"
6263
:emojis-suggestion-enabled="emojisSuggestionEnabled"
6364
:scroll-distance="scrollDistance"
@@ -188,6 +189,7 @@ export default {
188189
},
189190
roomInfoEnabled: { type: Boolean, default: false },
190191
textareaActionEnabled: { type: Boolean, default: false },
192+
textareaAutoFocus: { type: Boolean, default: true },
191193
userTagsEnabled: { type: Boolean, default: true },
192194
emojisSuggestionEnabled: { type: Boolean, default: true },
193195
roomMessage: { type: String, default: '' },

src/lib/Room/Room.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
:show-footer="showFooter"
137137
:accepted-files="acceptedFiles"
138138
:textarea-action-enabled="textareaActionEnabled"
139+
:textarea-auto-focus="textareaAutoFocus"
139140
:user-tags-enabled="userTagsEnabled"
140141
:emojis-suggestion-enabled="emojisSuggestionEnabled"
141142
:templates-text="templatesText"
@@ -207,6 +208,7 @@ export default {
207208
loadingRooms: { type: Boolean, required: true },
208209
roomInfoEnabled: { type: Boolean, required: true },
209210
textareaActionEnabled: { type: Boolean, required: true },
211+
textareaAutoFocus: { type: Boolean, required: true },
210212
userTagsEnabled: { type: Boolean, required: true },
211213
emojisSuggestionEnabled: { type: Boolean, required: true },
212214
scrollDistance: { type: Number, required: true },

src/lib/Room/RoomFooter/RoomFooter.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ export default {
235235
showFooter: { type: Boolean, required: true },
236236
acceptedFiles: { type: String, required: true },
237237
textareaActionEnabled: { type: Boolean, required: true },
238+
textareaAutoFocus: { type: Boolean, required: true },
238239
userTagsEnabled: { type: Boolean, required: true },
239240
emojisSuggestionEnabled: { type: Boolean, required: true },
240241
templatesText: { type: Array, default: null },
@@ -792,7 +793,10 @@ export default {
792793
this.files = []
793794
this.emojiOpened = false
794795
this.preventKeyboardFromClosing()
795-
setTimeout(() => this.focusTextarea(disableMobileFocus))
796+
797+
if (this.textareaAutoFocus || !initRoom) {
798+
setTimeout(() => this.focusTextarea(disableMobileFocus))
799+
}
796800
},
797801
resetTextareaSize() {
798802
if (this.getTextareaRef()) {

types/index.d.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ export interface Props {
163163
'current-user-id': StringNumber
164164
rooms: Rooms
165165
messages: Messages
166-
height?: string
167-
theme?: 'light' | 'dark'
168-
styles?: Record<string, Record<string, string>>
169-
'rooms-order'?: 'desc' | 'asc'
170-
'loading-rooms'?: boolean
166+
height?: string
167+
theme?: 'light' | 'dark'
168+
styles?: Record<string, Record<string, string>>
169+
'rooms-order'?: 'desc' | 'asc'
170+
'loading-rooms'?: boolean
171171
'rooms-loaded'?: boolean
172172
'room-id'?: StringNumber
173173
'load-first-room'?: boolean
@@ -178,6 +178,8 @@ export interface Props {
178178
'message-actions'?: MessageActions
179179
'message-selection-actions'?: CustomActions
180180
'templates-text'?: TemplatesText
181+
'textarea-action-enabled'?: boolean
182+
'textarea-auto-focus'?: boolean
181183
'auto-scroll'?: AutoScroll
182184
'show-search'?: boolean
183185
'show-add-room'?: boolean

0 commit comments

Comments
 (0)