Open TomJGooding opened 6 months ago
Just to note in case it is relevant, there are also a couple of existing issues relating to column widths:
I've had some time to look a bit into this. Still getting familiar with the Textual framework so apologies for any oversights here.
From what I'm seeing / intuiting
self._set_hover_cursor(False)
is called from action_select_cursor
_data_table.py:2580. This ultimately queues a refresh of the current region_on_idle
_data_table.py:1706 is now called where we have need to update dimensions. in _update_dimensions
_data_table.py:1275 the column width is updated, additionally the virtual_size
is updated to include the new rowself._set_hover_cursor
is not called in step one then the first render never happens and the entire table is re-rendered after the _on_idle
call i.e it works fine.
self._set_hover_cursor
would only cause the selected row to refreshself._set_hover_cursor
_on_idle
from the redraw
function (in a hacky way) it also works correctly as we've updated the column width before the render the first set of rows. Note that even if I do this still only the original set of rows and triggered to be rendered in the first cylce.self._set_hover_cursor
/ don't cause that premature renderHi @luked42 , @TomJGooding !
I also faced this issue and after some research, I found a workaround. Just change the line:
def on_data_table_row_selected(self, event: DataTable.RowSelected) -> None:
self.ideas.append(f"{self.ideas[-1] * 2}")
- self.redraw()
+ self.call_after_refresh(self.redraw)
I don't know if this is a good solution but I'm happy with it
This issue was originally posted in discussion #4463 by @luked42
There seems to be some strange behaviour with column widths when trying to update a
DataTable
on a*Selected
event.Here's an example based on the original post. When updating the table with the binding, the column widths work as expected. But if you swap this to update the table when a row is selected, it seems the column width isn't updated until the next refresh (when a row is hovered/highlighted, etc).