fix(chat): Disable chat input when sending input #1781
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While reading through the code (and debugging something else I was working on), I noticed that we globally disable the input when setting the input value to an empty string.
This initially struck me as a bug – we'd want to disable the send input button but not the whole input – until I realized that it's part of the input/response lifecycle and we're expecting the input to be re-enabled when the next response happens.
This PR updates the code to explicitly set
this.disabled = true
inChatInput.#sendInput()
along with a note about the purpose and how it's unset.While here, I also realized that if the user starts typing in the input while waiting for a response, but the user finishes before the response comes back, the input will be enabled but the send button won't. I added logic to recheck the button state when the input
disabled
attributes changes.