bubbles icon indicating copy to clipboard operation
bubbles copied to clipboard

Filtered item shows escaped style color

Open jeffdupont opened this issue 1 year ago • 8 comments

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

jeffdupont avatar Nov 07 '23 21:11 jeffdupont

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

meowgorithm avatar Nov 07 '23 22:11 meowgorithm

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

pjg11 avatar Nov 15 '23 21:11 pjg11

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 avatar Nov 16 '23 00:11 jeffdupont

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 avatar Nov 16 '23 00:11 jeffdupont

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

jeffdupont avatar Dec 29 '23 21:12 jeffdupont

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?

blvrd avatar Mar 21 '24 21:03 blvrd

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: @.***>

jeffdupont avatar Mar 21 '24 22:03 jeffdupont

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

blvrd avatar Apr 20 '24 16:04 blvrd