Skip to content

Select - incorrect width calculation for SelectOverlay #5280

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

Closed
MorningLightMountain713 opened this issue Nov 24, 2024 · 5 comments · Fixed by #5282
Closed

Select - incorrect width calculation for SelectOverlay #5280

MorningLightMountain713 opened this issue Nov 24, 2024 · 5 comments · Fixed by #5282

Comments

@MorningLightMountain713
Copy link

MorningLightMountain713 commented Nov 24, 2024

When setting width: auto for the SelectOverlay - it miscalculates the width by 2 every time. So the longest item in the select list is always split over 2 lines.

Textual Diagnostics

Versions

Name Value
Textual 0.86.3
Rich 13.9.3

Python

Name Value
Version 3.12.3
Implementation CPython
Compiler Clang 13.0.0 (clang-1300.0.29.30)
Executable /Users/davew/code/flux/flux_iso_installer/.venv/bin/python

Operating System

Name Value
System Darwin
Release 24.2.0
Version Darwin Kernel Version 24.2.0: Sun Nov 3 20:54:52 PST 2024; root:xnu-11215.60.405~54/RELEASE_X86_64

Terminal

Name Value
Terminal Application iTerm.app (3.5.10)
TERM xterm-256color
COLORTERM truecolor
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=145, height=38
legacy_windows False
min_width 1
max_width 145
is_terminal True
encoding utf-8
max_height 38
justify None
overflow None
no_wrap False
highlight None
markup None
height None

Here is an MRE:

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


class TallSelectApp(App[None]):
    CSS = """
        Screen {
            align: center middle;

            & > Select {
                width: 50;

                & > SelectOverlay {
                    max-height: 100vh;
                    width: auto;
                }
            }
        }
    """

    def compose(self) -> ComposeResult:
        yield Select(
            [(f"Option {idx + 1}", idx) for idx in range(100)]
            + [("Extra long option here", 100)],
            value=25,
        )


TallSelectApp().run()

Visual:

Screenshot 2024-11-24 at 4 47 05 PM

Copy link

We found the following entry in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@Zaloog
Copy link
Contributor

Zaloog commented Nov 24, 2024

Hi, @MorningLightMountain713
This has to do with the padding of the .option-list--option source
if you set that to 0 it fits.

image

@willmcgugan
Copy link
Collaborator

Try v0.87.1

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

@MorningLightMountain713
Copy link
Author

Try v0.87.1

Amazing. Thank you

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

Successfully merging a pull request may close this issue.

3 participants