Skip to content
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

Run the focus pass in post-processing for all events #604

Merged
merged 3 commits into from
Sep 23, 2024

Conversation

mwcampbell
Copy link
Contributor

Requesting and resigning focus can happen when handling pointer and accessibility events, not just keyboard events.

@mwcampbell
Copy link
Contributor Author

I didn't catch this before because the NVDA command for moving the input focus to the screen reader cursor happens to include the shift key, which triggered a text event. But Narrator's behavior was broken before, along with the WIP AccessKit Android adapter. And, even more basic than that, textboxes weren't actually receiving focus immediately when clicked.

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.

I think this should just be part of post_event_processing instead, based on my reading of linebender/rfcs#7

@mwcampbell mwcampbell changed the title Run the focus pass in response to pointer and accessibility events Run the focus pass in post-processing for all events Sep 20, 2024
@mwcampbell
Copy link
Contributor Author

OK, moved it into post_event_processing. Someone who knows the Masonry architecture better than me should make sure this is OK.

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.

I believe that this needs to be slightly further down in post_event_processing. cc @PoignardAzur

@@ -484,6 +483,8 @@ impl RenderRoot {

// --- MARK: POST-EVENT ---
fn post_event_processing(&mut self, widget_state: &mut WidgetState) {
run_update_focus_pass(self, widget_state);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditions under which run_update_focus_pass needs to happen are a bit unclear, and I suspect that logic should live inside the pass itself.

I think it only does something if:

  1. Reparenting happens (impossible)
  2. The currently focused node is now disabled
  3. The next focused node is different to the current focused node.

I think this should move to after the update_focus_chain pass as a first pass, with a comment like:

// TODO: Only run this pass if needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put it at the top because root_on_text_event used to make that call before post_event_processing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, indeed. This is why I've asked Olivier to weigh in.

I would approve optimistically if this were moved to be after update_focus_chain, presuming that testing still works.

@PoignardAzur
Copy link
Contributor

I would recommend running that pass twice: once in the event function and once after update focus chain like Daniel says.

Ultimately we should add a fixpoint loop that repeats all passes as per the RFC.

@DJMcNab
Copy link
Member

DJMcNab commented Sep 20, 2024

@PoignardAzur it might make sense for you to just push that change

@PoignardAzur
Copy link
Contributor

Done.

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.

This solves the issue mentioned on Zulip.

Of course, future work here is expected

@PoignardAzur PoignardAzur added this pull request to the merge queue Sep 23, 2024
Merged via the queue into main with commit 37af4b9 Sep 23, 2024
17 checks passed
@PoignardAzur PoignardAzur deleted the focus-pass-on-more-events branch September 23, 2024 11:02
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