Repository: Textualize/textual

Issue:
`DataTable` scrolling issues with `max-height: 100vh`
This follows on from discussion #4281 posted by @morelop about unexpected scrollbar behaviour with the `DataTable`.

Here's a slightly modified example from this discussion, where I've added borders to help show the container and table sizing. If you resize your terminal, the horizontal scrollbar isn't visible but also because of the `Footer` you can't scroll to the final row into view.

![image](https://github.com/Textualize/textual/assets/101601846/83fae6a5-d692-490a-904e-252b431a6e87)

I found this a bit surprising as I thought the DataTable had a `max-height: 100%` as per the FAQ - https://textual.textualize.io/FAQ/#why-doesnt-the-datatable-scroll-programmatically. But it seems this was changed to `100vh` in #3566, because "the previous value of 100% broke with horizontal layouts."

If you change the DataTable back to `max-height: 100%`, the example above works as expected. 

- Is the current behaviour with `max-height: 100vh` expected? Contrary to the note in the PR, this actually seems to break layouts based on this simple example.
- If this _is_ the expected behaviour, should the FAQ be updated?


```python
from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import DataTable, Footer


class ExampleApp(App):
    CSS = """
    Horizontal {
        border: solid red;
    }

    DataTable {
        border: solid pink;
    }
    """

    def compose(self) -> ComposeResult:
        with Horizontal():
            yield DataTable()
        yield Footer()

    def on_mount(self) -> None:
        table = self.query_one(DataTable)
        for col in range(0, 30):
            table.add_column(f"col{col}")
        for row in range(0, 30):
            data = [f"{row}x{col}" for col in range(0, 30)]
            table.add_row(*data)


if __name__ == "__main__":
    app = ExampleApp()
    app.run()
```


Discussion:
We found the following entry in the [FAQ](https://textual.textualize.io/FAQ/) which you may find helpful:


- [Why doesn't the `DataTable` scroll programmatically?](https://textual.textualize.io/FAQ/#why-doesnt-the-datatable-scroll-programmatically)

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by [FAQtory](https://github.com/willmcgugan/faqtory)
This is the expected behaviour, given the DataTable is larger than its container and the container doesn't scroll.

Having a table of height 100% caused a lot of confusion with auto height containers. Because the container is saying "I'll be as tall as the children" and the child is saying "Ill be as high as my parent.". Setting the default height to "100vh" fixes that, but it does mean that it may not fit inside a single screen.

It's simple enough to set the height to `100%` or `1fr` though.
Wasn't this issue with `auto` sized containers addressed in a later PR?

If I change the CSS in the example to the below, I don't see the issue you're describing on v0.52.1?

```python
    CSS = """
    Horizontal {
        border: solid red;
        height: auto;
    }

    DataTable {
        border: solid pink;
        max-height: 100%;
    }
    """
```
After looking back through the issues and PRs, it looks like this issue #2975 was fixed in #3814. 

Would you consider a PR to change the default `max-height` of the DataTable back to 100%?

Resolving patch:
diff --git a/src/textual/widgets/_data_table.py b/src/textual/widgets/_data_table.py
--- a/src/textual/widgets/_data_table.py
+++ b/src/textual/widgets/_data_table.py
@@ -266,7 +266,7 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
         background: $surface ;
         color: $text;
         height: auto;
-        max-height: 100vh;
+        max-height: 100%;
     }
     DataTable > .datatable--header {
         text-style: bold;


Test patch: