Skip to content

Commit 71aef35

Browse files
committed
snapshot
1 parent 85765f5 commit 71aef35

File tree

5 files changed

+228
-5
lines changed

5 files changed

+228
-5
lines changed

src/textual/_arrange.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,7 @@ def _arrange_dock_widgets(
167167
# Should not occur, mainly to keep Mypy happy
168168
raise AssertionError("invalid value for dock edge") # pragma: no-cover
169169

170-
align_offset = dock_widget.styles._align_size(
171-
(widget_width, widget_height), size
172-
)
173-
dock_region = dock_region.shrink(margin).translate(align_offset)
170+
dock_region = dock_region.shrink(margin)
174171
styles = dock_widget.styles
175172
offset = (
176173
styles.offset.resolve(

src/textual/css/styles.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ def _align_width(self, width: int, parent_width: int) -> int:
735735
offset_x = (parent_width - width) // 2
736736
else:
737737
offset_x = parent_width - width
738+
738739
return offset_x
739740

740741
def _align_height(self, height: int, parent_height: int) -> int:

src/textual/widgets/_toast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class ToastRack(Container, inherit_css=False):
150150
layer: _toastrack;
151151
width: 1fr;
152152
height: auto;
153-
dock: top;
153+
dock: bottom;
154154
align: right bottom;
155155
visibility: hidden;
156156
layout: vertical;
Lines changed: 154 additions & 0 deletions
Loading

tests/snapshot_tests/test_snapshots.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2913,3 +2913,74 @@ def compose(self) -> ComposeResult:
29132913
yield label
29142914

29152915
snap_compare(TabApp())
2916+
2917+
2918+
def test_dock_align(snap_compare):
2919+
"""Regression test for https://github.com/Textualize/textual/issues/5345
2920+
You should see a blue panel aligned to the top right of the screen, with a centered button."""
2921+
2922+
class MainContainer(Static):
2923+
def compose(self):
2924+
yield Sidebar()
2925+
2926+
# ~~~~ Sidebar widget ~~~~
2927+
class Sidebar(Static):
2928+
def compose(self):
2929+
yield StartButtons()
2930+
2931+
# ~~~~ the two buttons inside the sidebar ~~~~
2932+
class StartButtons(Static):
2933+
def compose(self):
2934+
yield Button("Start", variant="primary", id="start")
2935+
yield Button("Stop", variant="error", id="stop")
2936+
2937+
# ~~~~ main ~~~~
2938+
class Test1(App):
2939+
CSS = """
2940+
2941+
Screen {
2942+
layout: horizontal;
2943+
}
2944+
2945+
MainContainer {
2946+
width: 100%;
2947+
height: 100%;
2948+
background: red;
2949+
layout: horizontal;
2950+
}
2951+
2952+
2953+
Sidebar {
2954+
width: 40;
2955+
background: blue;
2956+
border: double green;
2957+
layout: vertical;
2958+
2959+
/* seems to be a weird interaction between these two */
2960+
/* V V V V */
2961+
dock: right;
2962+
align-horizontal: center;
2963+
2964+
}
2965+
2966+
StartButtons {
2967+
max-width: 18.5;
2968+
height: 5;
2969+
background: $boost;
2970+
padding: 1;
2971+
layout: horizontal;
2972+
}
2973+
#start {
2974+
dock: left;
2975+
}
2976+
#stop {
2977+
dock: left;
2978+
}
2979+
2980+
2981+
"""
2982+
2983+
def compose(self):
2984+
yield MainContainer()
2985+
2986+
snap_compare(Test1())

0 commit comments

Comments
 (0)