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

AUTO_FOCUS on App should apply to screen #2594

Closed
willmcgugan opened this issue May 17, 2023 · 5 comments · Fixed by #2628
Closed

AUTO_FOCUS on App should apply to screen #2594

willmcgugan opened this issue May 17, 2023 · 5 comments · Fixed by #2628
Assignees
Labels
enhancement New feature or request Task

Comments

@willmcgugan
Copy link
Collaborator

If you don't define a screen, there is no way to set AUTO_FOCUS. We should make AUTO_FOCUS on App apply to the default screen.

@davep davep added enhancement New feature or request Task labels May 17, 2023
@rodrigogiraoserrao rodrigogiraoserrao self-assigned this May 17, 2023
@rodrigogiraoserrao
Copy link
Contributor

rodrigogiraoserrao commented May 17, 2023

I tought about that but I concluded that if you want a non-default auto focus, you should create your own screen.
The default screen has limitations and is just a convenience, right?

If you still want App.AUTO_FOCUS, isn't there a possibility for people to think that App.AUTO_FOCUS should apply to all screens in the app?
In other words, I think it is weird to have App.AUTO_FOCUS to be special-cased.
“Special cases aren't special enough to break the rules.”

I suggest:

  • App.AUTO_FOCUS = "*" by default;
  • Screen.AUTO_FOCUS = None by default;

The auto focus is then taken from the app's and the screen's, with the screen's taking precedence if it is not None.

@rodrigogiraoserrao
Copy link
Contributor

@willmcgugan pinging you explicitly to ask for your feedback on this ^

@willmcgugan
Copy link
Collaborator Author

How then would you disable AUTO_FOCUS on a screen? Set it to empty string?

@rodrigogiraoserrao
Copy link
Contributor

After some discussion, we're going with this:

  • App.AUTO_FOCUS defaults to "*";
  • Screen.AUTO_FOCUS defaults to None;
  • Setting AUTO_FOCUS to "" explicitly disables it; and
  • Setting AUTO_FOCUS to None (on a screen) means we “inherit” the value of AUTO_FOCUS from the app.

rodrigogiraoserrao added a commit that referenced this issue May 23, 2023
Related issues: #2594.
@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.

3 participants