-
Notifications
You must be signed in to change notification settings - Fork 135
Fix focus chain code #1034
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
base: main
Are you sure you want to change the base?
Fix focus chain code #1034
Conversation
Fix bug where parts of the focus chain would disappear when widgets updated. Make Button accept focus. Make Prose not accept focus. Add TextEvent constructors.
// FIXME - Handle this properly | ||
if ctx.is_focus_target() { | ||
border_color = &BorderColor { | ||
color: Color::WHITE, | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drawing the focus outline should be done centrally in the paint
pass. Not inside of the widget.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disagree. I think it should ultimately be stylable, once we add pseudo-classes to the styling system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I strongly think widgets shouldn't have to do anything to get a focus outline. I think that's important for accessibility, or otherwise there is bound to be widgets where it has been forgotten. I think it could still be stylable even if provided outside of the Widget impl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a valid point. I'd recommend opening an issue about it, because I don't think this needs to be resolved in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is that globally providing this by default is more important than making it customizable, so I'd rather see this implemented in the paint
pass now and implementing customization afterwards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a bunch of complications in implementing "paint an outline by default on any focused widget" that I don't really want to deal with right now.
Seeing as that the status quo is that outline-by-default isn't implemented and this PR doesn't make it any less likely to get implemented, I'd rather avoid adding a drive-by requirement to it.
In other words, outline-by-default should be implemented in a separate PR. This PR fixes an important accessibility issue even without adding outline-by-default it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had implemented this locally in 10 lines without noticing any complications (might not be perfect but still better than nothing) ... but sure I can make a PR for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks. A couple of minor questions
const SPACE: &str = " "; | ||
match event { | ||
TextEvent::Keyboard(event) | ||
if event.key == Key::Character(SPACE.into()) && event.state.is_up() => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also support ↵ here?
@@ -796,7 +796,7 @@ impl<const EDITABLE: bool> Widget for TextArea<EDITABLE> { | |||
} | |||
|
|||
fn accepts_focus(&self) -> bool { | |||
true | |||
EDITABLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you confirm that accepts_focus
is only related to the focus chain? If so, I believe this behaviour to be correct.
The one complication is that it should ideally still be possible to select text inside a prose from only the keyboard, but I'm happy to defer that as a longer-term consideration.
Fix bug where parts of the focus chain would disappear when widgets updated. Make Button accept focus.
Make Prose not accept focus.
Add TextEvent constructors.