Open ardangelo opened 6 months ago
Adding a break
seems a good idea, as we don't need to check the rest of the children if we had one match. But another problem I see with this code is that &child
does not reference the value from flex.children
, but rather its copied value from the range loop.
It should probably look something like this instead:
- for _, child := range flex.children {
- if child.target == comp {
- flex.focused = &child
+ for i := range flex.children {
+ childp = &flex.children[i]
+ if childp.target == comp {
+ flex.focused = childp
flex.focused.Focus()
break
}
}
Thanks, updated PR with change.
In
gomuks
, ran into a tsrange problem withSetFocused
. It is not updatingflex.focused
unless abreak
is added to the loope, despite the condition matching and updating only once.Added debug logging,
The focused component is only matched and updated once, yet the focused target is still set to the older value.
Adding a break to the loop after a match is found fixes the issue.