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.
Fix summary:
This should fix the textinputs example, as the code is using KeyMsg. KeyMsg seems to have an issue with the v2 alpha where it appears that both KeyPressMsg and KeyReleaseMsg may be unintentionally being called sequentionally within
KeyMsg
. Just using one or the other should solve the issue for this (or at least be a temporary workaround). This issue also likely exists within other examples and may Need to be looked at separately.Specific Details on the Issue(s) Noticed
Specs/OS Information
(Get-Culture).KeyboardLayoutID
in powershell:1033
Context
During the process of developing a client side, terminal implementation of a game client in bubbletea, I happened to notice that after migrating from v1/main release to
v.2.0.0
that my nested models and general input were now skipping/taking two inputs:(I could only cycle between
Email
andSubmit
in this photo)After fiddling with this for a while (And nearly giving up), I tried a couple of other terminals. I noticed that in Windows Terminal, that there was a slight delay in between key presses that looked very deterministic as to when I pressed the key. Then I briefly recalled this section in the v2 alpha release notes (https://github.com/charmbracelet/bubbletea/releases/tag/v2.0.0-alpha.1):
My theory then became that at least on 1 complete keyboard press (at least within my environment), that because it's matching on both possible instances (and that people are slow in comparison to an action that's being performed); that within
Update
,KeyMsg
was matching on both possible inputs (as was noted) and running each time a full key stroke is hit. I assume this functionality was not intended, and thatKeyPress
was met as an Either Or operation and not an Either AND. That, or there has to be something within the Runtime that is triggering both events to catch onKeyPress
, causing this weird loop of Update being called twice.This makes the fix (at least workaround) relatively simple in that you either need to use
KeyPressMsg
orKeyReleaseMsg
instead of switching onKeyMsg
.There is also a separate bug that was noticed was that these weird escape characters seemed to appear when running the standalone windows terminal (I can also write this up as a separate bug if needed)
Standalone Windows Terminal:
changed spots on subsequent attempts:
I can open up a separate issue(s) for deeper investigation into both of these problems/bugs if needed as well.. Just depends on how much you want to break them down: