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

Filtered item shows escaped style color #430

Open
jeffdupont opened this issue Nov 7, 2023 · 8 comments
Open

Filtered item shows escaped style color #430

jeffdupont opened this issue Nov 7, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@jeffdupont
Copy link

Describe the bug
I have a list item with a colored style applied in the title. When I filter the list, it shows the colors escaped in the terminal

Setup
Build any list and add a lipgloss color style to the Title

Expected behavior
Color is still properly displayed for filtered items

Screenshots
Unfiltered:
Screenshot 2023-11-07 at 1 17 17 PM

Filtered:
Screenshot 2023-11-07 at 1 17 30 PM

@meowgorithm meowgorithm added the bug Something isn't working label Nov 7, 2023
@meowgorithm
Copy link
Member

meowgorithm commented Nov 7, 2023

Good catch. Do you have any code we can use to reproduce?

@pjg11
Copy link

pjg11 commented Nov 15, 2023

I came across a similar issue - charmbracelet/bubbletea#523
The sample program mentioned there produces a similar output.

@jeffdupont
Copy link
Author

Their response was to move it to a discussion but not address it. I think this is a bug as the rendering of the list item works, my filter shouldn't change how the list-item is rendered. It should just remove the items not part of the filter.

@jeffdupont
Copy link
Author

Good catch. Do you have any code we can use to reproduce?

Sorry, yes. The link from @pjg11 also has a good example of the same issue. But create any list and then in the Title() func just apply a lipgloss.Style to the title value. In my case it was

func (m model) Title() string {
    color := lipgloss.NewStyle().Background(lipgloss.Color("#fff000")).MarginRight(1).Render("X")
    return lipgloss.JoinHorizontal(lipgloss.Left, color, m.Title)
}

@jeffdupont
Copy link
Author

I pulled down the PR code to check it in my code and was able to confirm that PR would fix this issue.

@blvrd
Copy link

blvrd commented Mar 21, 2024

Looks like @muesli recommended defining your own itemDelegate in charmbracelet/bubbletea#523. Is that still the recommended way to work around this? Or should I try picking up where #452 left off?

@jeffdupont
Copy link
Author

jeffdupont commented Mar 21, 2024 via email

@blvrd
Copy link

blvrd commented Apr 20, 2024

For anyone coming across this thread, I've fixed my issue by defining a custom item delegate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants