Skip to content

fix: stop Enter propagation when transitioning to Input steps in appl…#34

Merged
cpaczek merged 1 commit into
cpaczek:mainfrom
hanbert:fix/input-enter-propagation
Apr 6, 2026
Merged

fix: stop Enter propagation when transitioning to Input steps in appl…#34
cpaczek merged 1 commit into
cpaczek:mainfrom
hanbert:fix/input-enter-propagation

Conversation

@hanbert
Copy link
Copy Markdown

@hanbert hanbert commented Apr 6, 2026

…y TUI

In OpenTUI's emitWithPriority, global listeners run first and renderable handlers are captured into an array afterwards. When handleKeys (a global listener) called showStep('name') or showStep('personality_custom'), the new Input widget was immediately focused inside showStep, registering its keypress handler before the renderable snapshot was taken. The same Enter keypress that triggered the transition was then delivered to the fresh Input, which instantly submitted an empty value and skipped the step.

Fix: call key.stopPropagation() after showStep() for the two transitions that create an Input widget (searching→name and personality→personality_custom), preventing the triggering Enter from reaching the newly-focused Input.

…y TUI

In OpenTUI's emitWithPriority, global listeners run first and renderable
handlers are captured into an array afterwards. When handleKeys (a global
listener) called showStep('name') or showStep('personality_custom'), the
new Input widget was immediately focused inside showStep, registering its
keypress handler before the renderable snapshot was taken. The same Enter
keypress that triggered the transition was then delivered to the fresh
Input, which instantly submitted an empty value and skipped the step.

Fix: call key.stopPropagation() after showStep() for the two transitions
that create an Input widget (searching→name and personality→personality_custom),
preventing the triggering Enter from reaching the newly-focused Input.
@hanbert
Copy link
Copy Markdown
Author

hanbert commented Apr 6, 2026

Fix: Stop Enter key propagation when transitioning to Input steps

Problem

When the user presses Enter to advance from the searching step to the name step (or from the personality selector to the personality_custom step), the same Enter keypress was being delivered to the newly-focused Input
widget. This caused the input to be immediately submitted with an empty value, effectively skipping the step.

Solution

Call key.stopPropagation?.() after calling showStep() for transitions that land on an Input step. This prevents the triggering Enter event from bubbling into the newly-focused widget.

The fix is guarded with optional chaining (?.) so it degrades gracefully if the event object doesn't support stopPropagation.

Changes

  • src/tui/apply/index.ts: Added stopPropagation call in two places — when transitioning from searching → name and from personality selector → personality_custom.

@cpaczek cpaczek merged commit 3ce3150 into cpaczek:main Apr 6, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants