-
Notifications
You must be signed in to change notification settings - Fork 905
Fix breakpoints #5785
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
Fix breakpoints #5785
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to add a separate snapshot test for vertical breakpoints?
The updated snapshots don't really demonstrate the change in layout, but also don't match the description in the docstring:
textual/tests/snapshot_tests/test_snapshots.py
Lines 4067 to 4073 in e5fd661
def test_breakpoints(snap_compare, size): | |
"""Test HORIZONTAL_BREAKPOINTS | |
You should see four terminals of different sizes with a grid of placeholders. | |
The first should have a single column, then two columns, then 4, then 6. | |
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for adding the snapshot test! But this still needs Will's approval (and an update to the CHANGELOG).
Please add an entry to the CHANGELOG, and we should be good to go! |
If someone is waiting for this pr, put following code in the head of source code, that will fix it: # patch is here
from textual.app import App
from textual.screen import Screen
from textual import events
class Screen(Screen):
async def _on_resize(self, event: events.Resize) -> None:
event.stop()
self._screen_resized(event.size)
for screen in self.app._background_screens:
screen._screen_resized(event.size)
horizontal_breakpoints = (
self.app.HORIZONTAL_BREAKPOINTS
if self.HORIZONTAL_BREAKPOINTS is None
else self.HORIZONTAL_BREAKPOINTS
) or []
vertical_breakpoints = (
self.app.VERTICAL_BREAKPOINTS
if self.VERTICAL_BREAKPOINTS is None
else self.VERTICAL_BREAKPOINTS
) or []
width, height = event.size
if horizontal_breakpoints:
self._set_breakpoints(width, horizontal_breakpoints)
if vertical_breakpoints:
self._set_breakpoints(height, vertical_breakpoints)
class App(App):
def get_default_screen(self) -> Screen:
"""Get the default screen.
This is called when the App is first composed. The returned screen instance
will be the first screen on the stack.
Implement this method if you would like to use a custom Screen as the default screen.
Returns:
A screen instance.
"""
return Screen(id="_default")
# patch is over |
Fix
VERTICAL_BREAKPOINTS
won't work.