GithubHelp home page GithubHelp logo

Comments (11)

zx8 avatar zx8 commented on June 25, 2024 1

@maaslalani Can this be re-opened? It seems #123 was reverted by commit 51377e6, so this is still an issue.

from huh.

maaslalani avatar maaslalani commented on June 25, 2024

Thanks so much for reporting this issue @dfalgout, I will take a look.

from huh.

testinfected avatar testinfected commented on June 25, 2024

@dfalgout I had the same issue and workaround was to define the form myself, set form theme then add the widget to the form

from huh.

meowgorithm avatar meowgorithm commented on June 25, 2024

Off the cuff, I'd guess that this is only happening on one-off elements, i.e.

huh.NewMultiSelect().
    WithTheme(customTheme()).
    Run()

Whereas the following works in my testing:

huh.NewForm().
    WithTheme(customTheme()).
    Run()

from huh.

caarlos0 avatar caarlos0 commented on June 25, 2024

my guess its a similar problem to #97

from huh.

jolheiser avatar jolheiser commented on June 25, 2024

This is indeed semi-specific to using fields directly, but it's only because they use the global Run internally, which is the source of the issue.

In order from call site:

return Run(m)

huh/run.go

Line 6 in 9cd22a8

form := NewForm(group).WithShowHelp(false)

huh/form.go

Lines 72 to 84 in 9cd22a8

f := &Form{
groups: groups,
paginator: p,
theme: ThemeCharm(),
keymap: NewDefaultKeyMap(),
width: 0,
height: 0,
results: make(map[string]any),
}
// NB: If dynamic forms come into play this will need to be applied when
// groups and fields are added.
f.WithTheme(f.theme)

huh/form.go

Lines 225 to 227 in 9cd22a8

for _, group := range f.groups {
group.WithTheme(theme)
}

huh/group.go

Lines 95 to 97 in 9cd22a8

for _, field := range g.fields {
field.WithTheme(t)
}

from huh.

maaslalani avatar maaslalani commented on June 25, 2024

I believe this issue should be solved if we simply check if the theme or keymap is already set on the field before overriding it. This will make things work individually and allow changing themes / keymaps for individual fields as part of a larger form as well.

from huh.

maaslalani avatar maaslalani commented on June 25, 2024

This should be fixed by #123, let us know if this works for you!

If it doesn't please feel free to re-open this issue or create a new one!

from huh.

mrkwtz avatar mrkwtz commented on June 25, 2024

Can confirm with 0.30.0 it's still an issue, please re-open.

from huh.

maaslalani avatar maaslalani commented on June 25, 2024

Apologies! Thanks for letting us know, re-opened the issue for now.

from huh.

maaslalani avatar maaslalani commented on June 25, 2024

Okay after a bunch of testing I believe I have solved it correctly this time, please do try it out and let me know if everything works correctly.

from huh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.