Skip to content

fix: Prevent double paste in focused field - #746

Merged
aymanbagabas merged 2 commits into
charmbracelet:mainfrom
ConnorsApps:fix-tea-paste-msg
Mar 10, 2026
Merged

aymanbagabas merged 2 commits into
charmbracelet:mainfrom
ConnorsApps:fix-tea-paste-msg

Conversation

@ConnorsApps

@ConnorsApps ConnorsApps commented Mar 9, 2026 •

Copy link
Copy Markdown
Contributor

Add tea.PasteMsg to the skip case alongside tea.KeyMsg in Group.Update's field range loop
This prevents the focused field from receiving the paste message twice (once in the broadcast, once in the focused-field update), fixing duplicated paste message.

Steps to reproduce

package main

import (
	"fmt"

	"charm.land/huh/v2"
)

func main() {
	name := ""
	huh.NewForm(
		huh.NewGroup(
			huh.NewInput().
				Title("What's your name?").
				Value(&name),
		),
	).Run()
	fmt.Println("Value of field:", name)
}
  1. Create a new go program in an empty folder with go mod init
  2. Paste this into program main.go
  3. Run the program, and paste a value into the input.

Testing

I've done very limited testing on my own bubbletea apps. I've added a test case that can reproduce this issue.

  • I have read CONTRIBUTING.md.
  • I have created a discussion that was approved by a maintainer (for new features).

@ConnorsApps
ConnorsApps requested a review from a team as a code owner March 9, 2026 20:00
@ConnorsApps
ConnorsApps requested review from andreynering and meowgorithm and removed request for a team March 9, 2026 20:00
@aymanbagabas

Copy link
Copy Markdown
Contributor

Than you so much @ConnorsApps!

@aymanbagabas
aymanbagabas merged commit 8ccc9e1 into charmbracelet:main Mar 10, 2026
13 of 20 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

⌂ 换网址