-
Notifications
You must be signed in to change notification settings - Fork 815
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
Auto expanding height #3122
Labels
enhancement
New feature or request
Comments
+1 this would be great to have. Rich's |
This does actually work. These is a edge case with an auto height table, in an auto height container. The max height of the table is set to 100% which prevents the table from expanding. We need a workaround for that/ |
willmcgugan
pushed a commit
that referenced
this issue
Sep 20, 2023
* DataTable new rows can have auto height. Related issue: #3122. * Test auto height computation in DataTable.add_row * Add snapshot test for add_row height=None. * Extract some styles logic into auxiliary methods. When adding a row with automatic height, I need to render the cells to compute their height. Instead of wasting that rendering, I want to do it well and then cache it, which means I need to reuse some of the logic of the other rendering methods. By extracting some logic, I'll be able to reuse it. * Cache auxiliary cell renderings. * Fix test import. * Set row height to 0 when adding auto-height row. * Remove superfluous cache clear. * Fix cache/typing issue. * Cache method to compute styles to render cell. We extract this logic into a method for two reasons. For one, having this as a method with an lru cache enables caching these auxiliary styles, which don't depend directly on the location of the cell, but instead depend on the values of 9 Boolean flags (making for a total of 512 possible combinations, versus the infinite number of different positions/states a cell can be in. Secondly, having this as a method allows me to compute these styles more easily from within _update_dimensions when trying to salvage the renderings of the cells of a new row that may have been pre-rendered with the wrong height. (See the following commits for more context.) * Perform surgery on the datatable cache. * Improve data table tests. * Reduce cache size. The first five parameters (is_header_cell, is_row_label_cell, is_fixed_style_cell, hover, and cursor) are the ones that change more frequently, so it is reasonable to fix the size of the cache at 32. Related comment: #3213 (comment) * Clear cache with other caches. Related comment: #3213 (comment).
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can set a height when you add a row to the DataTable, but there is currently no way to make it expand to fit the content.
I think that
add_row
should grow an option to automatically calculate the optimal height of a row.If we make this the default, we should be able to explicitly override it with a height. Perhaps a
height
of None means auto-detect, and a integer sets it explicitly. An explicit height will be faster, which might be significant if the user adds a lot of rows.The text was updated successfully, but these errors were encountered: