Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long multi-select cuts off items #67

Closed
chilicat opened this issue Dec 18, 2023 · 3 comments · Fixed by #71
Closed

Long multi-select cuts off items #67

chilicat opened this issue Dec 18, 2023 · 3 comments · Fixed by #71
Labels
enhancement New feature or request

Comments

@chilicat
Copy link

chilicat commented Dec 18, 2023

Describe the bug
If you create e.g. a NewMultiSelect with a lot of items than it happens that some items are not visible (depending on the terminal hright

To Reproduce
Steps to reproduce the behavior:

package main

import (
	"strconv"

	"github.com/charmbracelet/huh"
)

func main() {
	result := []string{}
	list := []huh.Option[string]{}
	for i := 0; i < 30; i++ {
		item := "item-" + strconv.Itoa(i)
		list = append(list, huh.NewOption(item, item))
	}
	sel := huh.NewMultiSelect[string]().Options(list...).Value(&result)
	form := huh.NewForm(
		huh.NewGroup(sel).Description("Long List"),
	)
	err := form.Run()
	if err != nil {
		panic(err)
	}
}

Run in a terminal which can show less then 30 lines.

Expected behavior
List should be scrollable

Screenshots

Screenshot 2023-12-18 at 09 41 59

Desktop (please complete the following information):

  • OSX, verson: v0.2.1
@kdssoftware
Copy link

I'm also having the same problem.
Maybe there is a workaround to this, if we can paginate using bubbletea?

@chilicat
Copy link
Author

I was thinking of the viewport:

Maybe it would be possible to implement SetMaxHeight method to limit the visible list space:

huh.NewMultiSelect[string]().SetMaxHeight(10)

@meowgorithm meowgorithm changed the title Long list cuts off items Long multi-select cuts off items Dec 18, 2023
@meowgorithm
Copy link
Member

meowgorithm commented Dec 18, 2023

Hi everyone. We have a candidate in #71 which solves for this. Feel free to give it a look.

@meowgorithm meowgorithm added the enhancement New feature or request label Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants