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

Create a base scrollable container class and move scrolling bindings to that #2332

Closed
davep opened this issue Apr 19, 2023 · 1 comment · Fixed by #2337
Closed

Create a base scrollable container class and move scrolling bindings to that #2332

davep opened this issue Apr 19, 2023 · 1 comment · Fixed by #2337
Assignees
Labels
enhancement New feature or request Task

Comments

@davep
Copy link
Contributor

davep commented Apr 19, 2023

Currently the navigation keys used in scrolling are all bound in Widget. This causes some problems, such as #2100. Given that no widget should be doing scrolling that doesn't inherit from a *Scroll container in some way, that code should move to a ScrollableContainer widget, where VerticalScroll and HorizontalScroll inherit form that.

This way the bulk of our widgets won't be competing with Widget when it comes to doing things with navigation key bindings.

See also #2331.

@davep davep added enhancement New feature or request Task labels Apr 19, 2023
@davep davep self-assigned this Apr 19, 2023
davep added a commit to davep/textual that referenced this issue Apr 20, 2023
The idea here is that not every widget will scroll, and as such not every
widget needs to have default bindings for calling the scrolling methods.
Generally scrolling is something done in a container.

These days we have *Scroll containers. As such it makes sense to introduce
the bindings in a common parent class for those containers.

This commit moves the binding from widget and creates that common parent
class, and then has HorizontalScroll and VerticalScroll inherit from it.

This is, it should be noted, a breaking change. Any code that creates a
scrolling widget that assumes that the bindings are just there, where that
widget doesn't inherit either from HorizontalScroll or VerticalScroll, will
suddenly find that scrolling with the keyboard is no longer possible.

See Textualize#2332.
davep added a commit to davep/textual that referenced this issue Apr 20, 2023
This is, to some degree, rendered moot by Textualize#2332, but for the moment it still
feels worth doing. The initial intention was to make sure that non-scrolling
containers and their child classes don't have bindings that may mask other
uses for navigation keys. However, it was realised that the "problem"
affected more than just containers (hence Textualize#2332).

But... on the off chance we add any more default bindings to
`Widget` (unlikely, but still), this will mean that they don't leak into the
containers unless we intend them to.

See Textualize#2331.
@github-actions
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
enhancement New feature or request Task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant