Evertras / bubble-table

A customizable, interactive table component for the Bubble Tea framework
MIT License
439 stars 25 forks source link

redraw after filtering #136

Closed dnalor closed 1 year ago

dnalor commented 1 year ago

When filtering a table while on a page which doesn't exist anymore after the filter is applied, an empty table is displayed. Programatically scolling to the first page has no effect. After a cursor movement, the newly filtered table is displayed correcty. Example:

                    m.currentFilter = m.filterTextInput.Value()
                    m.archTable = m.archTable.WithFilterInputValue( m.currentFilter)
                    m.archTable.Focused( true)
                    m.archTable.WithCurrentPage(1)
Evertras commented 1 year ago

There may be a bit of a misunderstanding for part of this. The functions you're calling on the table don't modify the underlying table. In fact, none of the exported functions mutate the underlying object, or at least they shouldn't. You need to keep doing what you started doing with the filter input:

m.archTable = m.archTable.WithFilterInputValue( m.currentFilter)
m.archTable = m.archTable.Focused( true)
m.archTable = m.archTable.WithCurrentPage(1)

Or:

m.archTable = m.archTable.WithFilterInputValue(m.currentFilter).Focused(true).WithCurrentPage(1)

That being said, I'm able to reproduce the bug where the table becomes empty while applying the filter via WithFilterInputValue, so let me fix that.

Evertras commented 1 year ago

Released https://github.com/Evertras/bubble-table/releases/tag/v0.15.0 , please let me know if this fixes the issue for you.

dnalor commented 1 year ago

Yes, this fixes it. Thanks!