Skip to content
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

Footer in ModalScreen lists ignored App keybindings #4517

Closed
twrightsman opened this issue May 17, 2024 · 4 comments
Closed

Footer in ModalScreen lists ignored App keybindings #4517

twrightsman opened this issue May 17, 2024 · 4 comments

Comments

@twrightsman
Copy link

When I add a Footer to a ModalScreen it lists the screen's keybindings as well as the App's keybindings, even though the App's keybindings are disabled. I would expect only the ModalScreen's keybindings to be displayed?

ModalScreen showing App keybindings too

Here is a diff to modal02.py that shows this:

@@ -15,6 +15,8 @@
 class QuitScreen(ModalScreen):
     """Screen with a dialog to quit."""
 
+    BINDINGS = [("f", "request_foo", "Foo")]
+    
     def compose(self) -> ComposeResult:
         yield Grid(
             Label("Are you sure you want to quit?", id="question"),
@@ -22,6 +24,7 @@
             Button("Cancel", variant="primary", id="cancel"),
             id="dialog",
         )
+        yield Footer()
 
     def on_button_pressed(self, event: Button.Pressed) -> None:
         if event.button.id == "quit":
@@ -29,6 +32,9 @@
         else:
             self.app.pop_screen()
 
+    def action_request_foo(self) -> None:
+        print("I pity thee")
+
 
 class ModalApp(App):
     """An app with a modal dialog."""
Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@twrightsman
Copy link
Author

I made a patch that fixes the Footer (main...twrightsman:textual:main), but haven't yet run the test suite.

There is probably a better way to do this; maybe just iterating over _modal_binding_chain in namespace_bindings rather than just replicating _modal_binding_chain's behavior and checking is_modal.

@twrightsman
Copy link
Author

Fixed in 0.61

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant