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

Invalid state around CanBeFocused is possible. #21

Open
Mattias1 opened this issue Oct 23, 2020 · 1 comment
Open

Invalid state around CanBeFocused is possible. #21

Mattias1 opened this issue Oct 23, 2020 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest Good issues to contribute as part of Hacktoberfest

Comments

@Mattias1
Copy link
Contributor

🐛 Bug Report

A Control has a IsFocused and a CanBeFocused property. A control could change it's CanBeFocused property after it receives Focus, allowing the Control to be in an invalid state. Currently the abstract Control class is relying on his subclasses to behave properly and not do this, which breaks proper encapsulation.

Context

The currently latest version (2020-10-23), I do not know what that version is (it sais 1.0.0 in the properties everywhere, but I don't really believe that).

Expected behavior

The CanBeFocused property should not allow setting it to an invalid state. Either refuse to set CanBeFocused to false if it's currently Focused (probably by throwing), or by Unfocusing when CanBeFocused is set to false.

To reproduce

Create a custom control, give it focus, set that it can't be focused and voila, you have a focused unfocusable object.

@Mattias1 Mattias1 added the bug Something isn't working label Oct 23, 2020
@tomrijnbeek
Copy link
Member

My preference would be to have the control be unfocused if CanBeFocused is set to false. For example, a hidden controlmay set this property to false, and still having the focus exist would be unexpected.

Focus probably needs another revisit, because it doesn't work entirely intuitive right now, but unfocusing the control when CanBeFocused is set to false sounds like a net positive either way.

@tomrijnbeek tomrijnbeek added good first issue Good for newcomers bug Something isn't working hacktoberfest Good issues to contribute as part of Hacktoberfest and removed bug Something isn't working labels Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest Good issues to contribute as part of Hacktoberfest
Projects
None yet
Development

No branches or pull requests

2 participants