Fix crash when inserting an emoji into a max length reaction

This commit is contained in:
Stanko K.R.
2025-12-03 10:32:49 +01:00
parent bf858c8e02
commit f8eda42187
@@ -6,7 +6,12 @@ export default class extends Controller {
insertEmoji(event) {
const emojiChar = event.target.getAttribute("data-emoji")
const value = this.inputTarget.value
this.inputTarget.value = `${value}${emojiChar}`
const newValue = `${value}${emojiChar}`
if (this.inputTarget.maxLength > 0 && newValue.length <= this.inputTarget.maxLength) {
this.inputTarget.value = newValue
}
this.inputTarget.focus()
}
}