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

Select initial value is out of view when first expanded #5255

Closed
TomJGooding opened this issue Nov 18, 2024 · 7 comments
Closed

Select initial value is out of view when first expanded #5255

TomJGooding opened this issue Nov 18, 2024 · 7 comments
Assignees

Comments

@TomJGooding
Copy link
Contributor

When the Select widget is first expanded, the initial selected value is out of view when it appears further down in the list of options.

from textual.app import App, ComposeResult
from textual.widgets import Select


class SelectApp(App):
    def compose(self) -> ComposeResult:
        yield Select.from_values(
            range(20),
            value=15,
        )


if __name__ == "__main__":
    app = SelectApp()
    app.run()
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

@TomJGooding
Copy link
Contributor Author

I think the problem is when the Select is first expanded, where this calls OptionList.scroll_to_highlight the region values here are all zeros:

self.scroll_to_region(
Region(0, y, self.scrollable_content_region.width, height),
force=True,
animate=False,
top=top,
)

@TomJGooding
Copy link
Contributor Author

TomJGooding commented Nov 30, 2024

After testing with the latest version (0.88.1), expanding the Select with the keyboard now seems to works as expected, but not when clicked with the mouse.

Maybe rather than self.call_after_refresh added on L523, should it be overlay.call_after_refresh...?

@willmcgugan
Copy link
Collaborator

That does appear to be a fix!

@willmcgugan
Copy link
Collaborator

But I can replicate the issue in the demo. Curious.

@TomJGooding
Copy link
Contributor Author

It looks like this was resolved in #5314.

I noticed a difference in the scroll behaviour when first expanded with the mouse vs the keyboard, but that probably should be a new issue.

Copy link

github-actions bot commented Dec 6, 2024

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

No branches or pull requests

2 participants