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

The Input suggester should only show suggestions if an active edit is happening #3811

Closed
davep opened this issue Dec 5, 2023 · 1 comment · Fixed by #4335
Closed

The Input suggester should only show suggestions if an active edit is happening #3811

davep opened this issue Dec 5, 2023 · 1 comment · Fixed by #4335
Assignees
Labels
enhancement New feature or request Task

Comments

@davep
Copy link
Contributor

davep commented Dec 5, 2023

Somewhat following on from #3806, I feel that the suggester API for Input is a wee bit too eager to make a suggestion. Consider the following code:

from textual.app import App, ComposeResult
from textual.suggester import SuggestFromList
from textual.widgets import Input

class SuggestTooSoon(App[None]):

    def compose(self) -> ComposeResult:
        yield Input("TeX", suggester=SuggestFromList([
            "textual"
        ], case_sensitive=False))

if __name__ == "__main__":
    SuggestTooSoon().run()

imagine this is a field in a dialog where the Input has been populated from some external database. The value in the field is the correct value. On the other hand the current approach suggests it might not be:

Screenshot 2023-12-05 at 11 09 13

The proposal here is that we modify the suggester API so that it doesn't make a visible suggestion until the user makes an edit. The "correct" value in that Input is TeX -- no suggestion needed -- but the moment the user backspaces the X, or adds a t, then it makes sense that a suggestion is made.

It may be that the current behaviour is desirable in some situations, in which case it would be fine to make this uneager approach an option.

@davep davep added enhancement New feature or request Task labels Dec 5, 2023
@davep davep self-assigned this Mar 25, 2024
davep added a commit to davep/textual that referenced this issue Mar 25, 2024
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