Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix focus chain code #1034

wants to merge 1 commit into from

Conversation

PoignardAzur
Copy link
Contributor

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.

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.
Comment on lines +246 to +251
// FIXME - Handle this properly
if ctx.is_focus_target() {
border_color = &BorderColor {
color: Color::WHITE,
};
}
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Member

@DJMcNab DJMcNab left a 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() =>
Copy link
Member

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants