Skip to content

Conversation

@IanRawley
Copy link
Contributor

What does the pull request do?

Changes XYFocus.IsValidCandidate to check IsEffectivelyEnabled and IsEffectivelyVisible instead of IsEnabled and IsVisible

What is the current behavior?

When a control is effectively disabled (for example a Button bound to a Command with CanExecute = false) XYFocus will still consider it a valid candidate. If such a control ends up being the best candidate it turns into a focus roadblock as it cannot actually be focused.

What is the updated/expected behavior with this PR?

Controls that are disabled by means other than changing IsEnabled are skipped for XYFocus, preventing them from blocking navigation.

How was the solution implemented (if it's not obvious)?

XYFocus.IsValidCandidate() was changed to check IsEffectivelyEnabled and IsEffectivelyVisible instead of IsEnabled and IsVisible

Checklist

Breaking changes

Behavioural changes if effectively disabled controls were being used as navigation blockers.

Obsoletions / Deprecations

None

Fixed issues

Fixes #20239

Notes

I am a little concerned by IsValidFocusSubtree.

// We don't need to check for effective values, as we've already checked parents of this subtree on previous steps. 
return candidate.IsVisible &&
       candidate.IsEnabled;

It says effective values are checked, but I can't see where (other than the changes I have just made). This does seem to be related to focus engagement though, which as far as I know isn't implemented.

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0060679-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul added bug backport-candidate-11.3.x Consider this PR for backporting to 11.3 branch labels Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-candidate-11.3.x Consider this PR for backporting to 11.3 branch bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XYFocus attempts to focus Buttons which are disabled

3 participants