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

Shouldn't be able to type in to a disabled input #2772

Closed
willmcgugan opened this issue Jun 12, 2023 · 4 comments · Fixed by #2776
Closed

Shouldn't be able to type in to a disabled input #2772

willmcgugan opened this issue Jun 12, 2023 · 4 comments · Fixed by #2776
Assignees
Labels
bug Something isn't working Task

Comments

@willmcgugan
Copy link
Collaborator

If a widget is enabled and has focus, then subsequently disabled, you are still able to type.

When an input is disabled, it should ignore all interactions.

@rodrigogiraoserrao rodrigogiraoserrao self-assigned this Jun 13, 2023
@rodrigogiraoserrao rodrigogiraoserrao added bug Something isn't working Task labels Jun 13, 2023
@rodrigogiraoserrao
Copy link
Contributor

rodrigogiraoserrao commented Jun 13, 2023

I cannot reproduce this, @willmcgugan.

Repro app

@darrenburns
Copy link
Member

Can't reproduce with this app:

class DisabledInput(App):
    BINDINGS = [
        Binding("ctrl+n", "disable_input", "Disable Input"),
    ]

    def compose(self) -> ComposeResult:
        yield Input("Disabled")

    def action_disable_input(self) -> None:
        self.query_one(Input).disabled = True


app = DisabledInput()
if __name__ == '__main__':
    app.run()

@davep
Copy link
Contributor

davep commented Jun 13, 2023

This does it:

from textual.app        import App, ComposeResult
from textual.containers import Vertical
from textual.widgets    import Input

class DisableFocus( App[ None ] ):

    BINDINGS = [
        ( "ctrl+z", "disable" ),
    ]

    def compose( self ) -> ComposeResult:
        with Vertical():
            yield Input()

    def action_disable( self ) -> None:
        self.query_one( Vertical ).disabled = not self.query_one( Vertical ).disabled

if __name__ == "__main__":
    DisableFocus().run()

davep added a commit to davep/textual-sandbox that referenced this issue Jun 13, 2023
@github-actions
Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

willmcgugan pushed a commit that referenced this issue Jun 14, 2023
* Add regression test for #2772.

* Remove focus on nested disabled widgets.

* Optimisation.

Related comments: #2776 (comment)

* Fix tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants