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

RadioSet redux #2372

Merged
merged 10 commits into from
Apr 25, 2023
Merged

RadioSet redux #2372

merged 10 commits into from
Apr 25, 2023

Conversation

davep
Copy link
Contributor

@davep davep commented Apr 25, 2023

A revisit of RadioSet to improve how it works in the user interface. This can be considered a breaking change in that, while the look of the user interface hasn't really changed, the way the user interacts with it, and to some degree the way the developer interacts with it, has changed.

The main drivers for this change are:

  • Tab and Shift+Tab should pass into and out of the RadioSet in one action -- no more navigating all of the contained RadioButtons as focusable widgets in their own right.
  • The RadioButtons are now navigated using cursor keys.

This makes it far easier for a user to navigate into a RadioSet, make any change, and then move on to the next widget on a wider form.

While developers should have been treating RadioSet as a "black box" anyway, the breaking change for them is that if they didn't treat it as such, any code doing things "under the hood" might now have unexpected results.

davep added 7 commits April 25, 2023 10:13
With this commit a RadioSet becomes something you can tab into and out of
with just one keypress; navigation of the buttons within moves to being done
with the cursor keys instead.

See Textualize#2368.
This is necessary now that a focused RadioSet has acquired a border colour
similar to that if a focused Input.
Initially we went with a RadioSet being a simple container of RadioButtons,
with the user navigating the RadioButtons like you would any other set of
widgets. This was fine but it became pretty clear pretty quickly that having
to tab through a non-trivial collection of buttons in a set to get to the
next widget wasn't ideal.

This commit, satisfying Textualize#2368, takes over the navigation of the buttons
within the container, makes the container itself a focusable widget, and
sets up some new bindings to allow a more natural and efficient interaction
with the set.
@davep davep self-assigned this Apr 25, 2023
@davep davep added enhancement New feature or request Task labels Apr 25, 2023
This keeps randomly failing in Windows in CI; multiple subsequent runs gets
it going in the end, normally one further fail at a time. So let's throw a
wee wait on the end and see if that helps.
@davep davep marked this pull request as ready for review April 25, 2023 14:36
@@ -295,7 +295,7 @@ def test_demo(snap_compare):
"""Test the demo app (python -m textual)"""
assert snap_compare(
Path("../../src/textual/demo.py"),
press=["down", "down", "down"],
press=["down", "down", "down", "wait:250"],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Little out-of-scope tweak to the demo snapshot; in the hope that it'll stop it being a problem when running CI tests in Windows.

Based on a sample of 1 run it seems to have done the trick!

davep added 2 commits April 25, 2023 15:41
250 worked; so let's try it lower.
Waiting 100 resulted in a fail, so let's bump back up again.
@davep davep merged commit 441b98d into Textualize:main Apr 25, 2023
@davep davep deleted the radioset-redux branch April 25, 2023 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Radioset should focus as a single widget, and use cursor keys to navigate options
2 participants