Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/toad/widgets/comms_command_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@
from textual.worker import Worker, WorkerFailed
from toad.forms.editors import MultilineEditor, ValueEditor
from toad.forms.form_view import InlineFormView
from toad.native_style import AutoWidth, EllipsisOverflow, SideMargin
from toad.native_style import (
AutoWidth,
DockedBottom,
EllipsisOverflow,
FillHeight,
SideMargin,
)
from toad.screens.modal import (
CenteredScreen,
DismissibleScreen,
Expand Down Expand Up @@ -168,13 +174,17 @@ def apply_native_layout(self) -> None:
self.styles.padding = (1, 2)


class CommandFormScroll(FillHeight, VerticalScroll):
"""The form scrolls within the space left above its fixed command footer."""


class CommandTitle(EllipsisOverflow, Static):
def apply_native_layout(self) -> None:
super().apply_native_layout()
self.styles.max_height = 3


class CommandButtons(Horizontal):
class CommandButtons(DockedBottom, Horizontal):
def apply_native_layout(self) -> None:
super().apply_native_layout()
self.styles.height = 3
Expand Down Expand Up @@ -231,10 +241,10 @@ def __init__(self, definition: TargetAction, target: str, fields: tuple[TargetFi
def compose(self) -> ComposeResult:
with CommandBox():
yield CommandTitle(f"{self.definition.label} — {self.target}", markup=False)
with VerticalScroll():
with CommandFormScroll():
yield CommandConfirmation('', markup=False)
yield self.form
yield CommandConfirmed('I confirm this operation')
yield CommandConfirmed('I confirm this operation')
with CommandButtons():
yield ApplyCommandButton('Apply', variant='primary')
yield CancelCommandButton('Cancel')
Expand Down
18 changes: 17 additions & 1 deletion tests/textual/test_application_actions_in_the_running_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
from toad.preferences import SETTINGS
from toad.screens.keymap import KeymapScreen
from toad.screens.settings import SettingsScreen
from toad.widgets.comms_command_dialog import CatalogField, CatalogFieldSelection
from toad.widgets.comms_command_dialog import (
CatalogField,
CatalogFieldSelection,
CommandFormScroll,
)
from toad.widgets.comms_sidebar import CommsSidebar, NewSessionButton
from toad.widgets.footer import ToadFooter
from toad.widgets.session_tabs import SessionTabClose
Expand Down Expand Up @@ -180,8 +184,20 @@ def call(self, request):
parameter = dialog.choices['model'].parameter
assert selection.current == FieldCodec.encode(parameter.value)
assert selection.choices == tuple(choice for choice in parameter.options if choice.value is not None)
await ui.textual[1].resize_terminal(80, 24)
await ui.step()
button = dialog.query_one(ApplyCommandButton)
await ui.until(lambda: not button.disabled, why="the command values to be accepted")
await ui.until_clickable(button, why="the fixed create control to remain visible before scrolling")
lower = next(reversed(dialog.form.values.values())).editor
lower.scroll_visible(animate=False, immediate=True)
assert isinstance(lower, ChoicesEditor)
await ui.step()
await ui.textual[1].click(lower, offset=(3, 1))
await ui.until(lambda: lower.expanded, why="the scrolled lower field to open its actual choices")
await ui.press('escape')
assert dialog.query_one(CommandFormScroll).scroll_y > 0
await ui.until_clickable(button, why="the fixed create control to remain visible after scrolling")
editor = dialog.form.values["name"].editor
editor.scroll_visible(animate=False, immediate=True)
await ui.until_clickable(editor, why="the name editor to be visible")
Expand Down
Loading