You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have you checked against the most recent version of Textual? Yes
Please give a brief but clear explanation of the issue. If you can, include a complete working example that demonstrates the bug. Check it can run without modifications.
A screen pushed inside a CommandPaletteSystemCommand callback does not receive the dismiss result.
Here is a slightly tweaked version of the QuitScreen example where it also calls the same function from the command palette. You can see that the key binding still quits the app as normal. If you do it from the command palette it does not quit. Does not matter if it is Modal or not.
from textual.app import App, ComposeResult, SystemCommand
from textual.containers import Grid
from textual.screen import ModalScreen, Screen
from textual.widgets import Button, Footer, Header, Label
class QuitScreen(ModalScreen[bool]):
"""Screen with a dialog to quit."""
def compose(self) -> ComposeResult:
yield Grid(
Label("Are you sure you want to quit?", id="question"),
Button("Quit", variant="error", id="quit"),
Button("Cancel", variant="primary", id="cancel"),
id="dialog",
)
def on_button_pressed(self, event: Button.Pressed) -> None:
if event.button.id == "quit":
self.dismiss(True)
else:
self.dismiss(False)
class ModalApp(App):
"""An app with a modal dialog."""
# CSS_PATH = "modal01.tcss"
BINDINGS = [("q", "request_quit", "Quit")]
def compose(self) -> ComposeResult:
yield Header()
yield Footer()
def get_system_commands(self, screen: Screen) -> Iterable[SystemCommand]:
yield from super().get_system_commands(screen)
yield SystemCommand("try a modal quit dialog", "this should work", self.action_request_quit)
def action_request_quit(self) -> None:
"""Action to display the quit dialog."""
def check_quit(quit: bool | None) -> None:
"""Called when QuitScreen is dismissed."""
if quit:
self.exit()
self.push_screen(QuitScreen(), check_quit)
if __name__ == "__main__":
app = ModalApp()
app.run()
Have you checked closed issues? Yes
Have you checked against the most recent version of Textual? Yes
Please give a brief but clear explanation of the issue. If you can, include a complete working example that demonstrates the bug. Check it can run without modifications.
A screen pushed inside a
CommandPalette
SystemCommand
callback does not receive the dismiss result.Here is a slightly tweaked version of the QuitScreen example where it also calls the same function from the command palette. You can see that the key binding still quits the app as normal. If you do it from the command palette it does not quit. Does not matter if it is Modal or not.
Textual Diagnostics
Versions
Python
Operating System
Terminal
Rich Console options
The text was updated successfully, but these errors were encountered: