Merge pull request #1838 from basecamp/fix-crash-when-inserting-an-emoji-in-a-maxlength-reaction

Fix crash when inserting an emoji into a max length reaction
This commit is contained in:
Stanko Krtalić
2025-12-03 10:36:38 +01:00
committed by GitHub
@@ -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()
}
}