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

check parent focus #4236

Merged
merged 6 commits into from
Feb 29, 2024
Merged

check parent focus #4236

merged 6 commits into from
Feb 29, 2024

Conversation

willmcgugan
Copy link
Collaborator

Clicking the screen should check for focusable ancestors, rather than just the widget underneath the mouse.

@davep davep linked an issue Feb 28, 2024 that may be closed by this pull request
Copy link
Contributor

@rodrigogiraoserrao rodrigogiraoserrao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick Q before merging

Comment on lines +329 to +330
if isinstance(node, Widget) and node.focusable:
return node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to guard against a pathological case where the node that was clicked isn't focusable, one of its DOM ancestors is focusable, but the position clicked doesn't fall within said ancestor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That rarely occurs, since widgets are clipped within the boundary of their parents. The one exception is the overlay rule, and we decided that if you click on the overlay it should focus the DOM parent, even if it isn't directly under the mouse.

@willmcgugan willmcgugan merged commit 6157cb9 into main Feb 29, 2024
20 checks passed
@willmcgugan willmcgugan deleted the focus-parent branch February 29, 2024 11:10
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 this pull request may close these issues.

Mouse-driven focus does not behave as expected.
2 participants