charmbracelet / bubbles

TUI components for Bubble Tea 🫧
MIT License
5.37k stars 252 forks source link

Filtered item shows escaped style color #430

Open jeffdupont opened 10 months ago

jeffdupont commented 10 months ago

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 commented 10 months ago

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

pjg11 commented 10 months ago

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

jeffdupont commented 10 months ago

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 commented 10 months ago

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 commented 8 months ago

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

blvrd commented 5 months ago

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

jeffdupont commented 5 months ago

Latest version seemed to correct it for me.

On March 21, 2024, Github Notification @.***> wrote:

Looks like @muesli https://github.com/muesli recommended defining your own itemDelegate https://github.com/charmbracelet/bubbletea/blob/master/examples/list- simple/main.go#L29-L50 in charmbracelet/bubbletea#523 https://github.com/charmbracelet/bubbletea/issues/523. Is that still the recommended way to work around this? Or should I try picking up where #452 https://github.com/charmbracelet/bubbles/pull/452 left off?

— Reply to this email directly, view it on GitHub https://github.com/charmbracelet/bubbles/issues/430#issuecomment- 2013759579, or unsubscribe https://github.com/notifications/unsubscribe- auth/AABUP6C4VF4D6I5TTURUGMTYZNFEZAVCNFSM6AAAAAA7B3B2OOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJTG42TSNJXHE. You are receiving this because you authored the thread.Message ID: @.***>

blvrd commented 4 months ago

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