Skip to content

Invalid state around CanBeFocused is possible. #21

@Mattias1

Description

@Mattias1

🐛 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershacktoberfestGood issues to contribute as part of Hacktoberfest

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions