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

RadioButton still selectable by keyboard when disabled #3839

Closed
geoff-va opened this issue Dec 8, 2023 · 5 comments · Fixed by #3872
Closed

RadioButton still selectable by keyboard when disabled #3839

geoff-va opened this issue Dec 8, 2023 · 5 comments · Fixed by #3872
Assignees
Labels
bug Something isn't working Task

Comments

@geoff-va
Copy link

geoff-va commented Dec 8, 2023

It appears that when a RadioButton is disabled, click events no longer respond as expected, but you can still navigate to it with the keyboard and select it with space or enter.

radio-select-disabled

from textual.app import App, ComposeResult
from textual.widgets import RadioButton, RadioSet, Static


class Test(App):
    DEFAULT_CSS = """
    RadioButton:disabled {
        color: red;
    }
    """

    def compose(self) -> ComposeResult:
        with RadioSet():
            yield RadioButton("Enabled 1")
            yield RadioButton("Disabled 2", disabled=True)
            yield RadioButton("Disabled 3", disabled=True)
        yield Static("Selected:", id="selected")

    def on_radio_set_changed(self, radio_set: RadioSet.Changed) -> None:
        self.query_one("#selected").update(f"Selected: {radio_set.pressed.label}")


if __name__ == "__main__":
    app = Test()
    app.run()

Textual Diagnostics

Versions

Name Value
Textual 0.44.1
Rich 13.7.0

Python

Name Value
Version 3.8.10
Implementation CPython
Compiler Clang 12.0.5 (clang-1205.0.22.9)
Executable /Users/geoff/Documents/projects/test/venv/bin/python

Operating System

Name Value
System Darwin
Release 22.5.0
Version Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:19 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T8103

Terminal

Name Value
Terminal Application vscode (1.85.0)
TERM xterm-256color
COLORTERM truecolor
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=158, height=40
legacy_windows False
min_width 1
max_width 158
is_terminal True
encoding utf-8
max_height 40
justify None
overflow None
no_wrap False
highlight None
markup None
height None
@davep davep added bug Something isn't working Task labels Dec 8, 2023
@Textualize Textualize deleted a comment from github-actions bot Dec 8, 2023
@davep
Copy link
Contributor

davep commented Dec 8, 2023

Good spot: for clarification, this looks to be a RadioSet bug, not a RadioButton bug.

@willmcgugan
Copy link
Collaborator

This may impact other widgets where you can press a key to select. Suggest we also check other widgets.

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

@rodrigogiraoserrao
Copy link
Contributor

rodrigogiraoserrao commented Dec 15, 2023

This may impact other widgets where you can press a key to select. Suggest we also check other widgets.

You were right.

  • SelectionList and OptionList allow highlighting disabled items (with keyboard & mouse) but don't allow selection.
  • ListView allows highlighting with keyboard but not with mouse (and doesn't allow selection).
  • As of PR 3872, RadioSet doesn't allow neither navigation nor selection.

I feel like we should disable navigation everywhere and instead Up / Down should only go through enabled children.

@willmcgugan
Copy link
Collaborator

Agree, please adds that to ToDo

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