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

Copy edit on Focus page #10432

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Copy edit on Focus page #10432

wants to merge 9 commits into from

Conversation

atsansone
Copy link
Contributor

Fixes #10168

@flutter-website-bot
Copy link
Collaborator

flutter-website-bot commented Apr 19, 2024

Visit the preview URL for this PR (updated for commit f64e8c4):

https://flutter-docs-prod--pr10432-fix-10168-g1r5uhxa.web.app

Copy link
Contributor

@sfshaza2 sfshaza2 left a comment

Choose a reason for hiding this comment

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

I'm having problems with some of the new sections of this page. Meanings of some terms have subtly changed and, in some cases, concepts seem less clear. @gspencergoog, can you please take a look?

src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
Copy link
Contributor

@sfshaza2 sfshaza2 left a comment

Choose a reason for hiding this comment

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

Also, @parlough, is this what you had in mind when you filed an issue?

This system directs keyboard input to a particular part of an app.
To "focus" the input to part of an app,
users tap or click on the desired UI element.
Once in focus, text entered with the keyboard appears in that element.
Copy link
Contributor

Choose a reason for hiding this comment

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

Text doesn't always appear: if the focused element isn't a text field, then it doesn't necessarily show anything: think of a game where hitting the "s" key moves a game piece up, but "s" never appears anywhere.

That's why it said "flows to that part of": it's an event stream (of keyboard events) that you're capturing with focus. Text fields convert it to visible text, but almost any other widget will just eat it and perform some operation.

users tap or click on the desired UI element.
Once in focus, text entered with the keyboard appears in that element.
This continues until the focus moves to another element in the app.
App users also can press a particular keyboard shortcut to move focus,
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just leave out "particular". Any key sequence can be assigned to move focus, Tab and Shift+Tab are just the defaults.

* How to set focus order
:::

Some developers have expressed confusion about how to define and
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this section be set off better in a "note" box?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe? But not sure stacking two boxes atop each other would look good.

are listed after this section.

**Focus tree**
: A sparse mirror of the widget tree that represents all the widgets
Copy link
Contributor

Choose a reason for hiding this comment

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

This is generally correct. There are cases where the focus tree doesn't mirror the widget tree, but they are esoteric.

src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
Comment on lines 54 to 61
: A focus node that has focus where key events start propagating to
the primary focus node and its ancestors.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
: A focus node that has focus where key events start propagating to
the primary focus node and its ancestors.
: The focused node that is the first to receive key events before propagating them to its ancestors.

src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
Copy link
Contributor Author

@atsansone atsansone left a comment

Choose a reason for hiding this comment

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

Thanks @gspencergoog for the updates!

@atsansone
Copy link
Contributor Author

PTAL @gspencergoog

@parlough parlough added the review.tech Awaiting Technical Review label May 2, 2024
@parlough parlough requested a review from gspencergoog May 2, 2024 13:18
@atsansone
Copy link
Contributor Author

This article explains how to direct keyboard input.
If your app uses a physical keyboard, like desktop and web apps,
keep reading. If your app won't use a physical keyboard,
you can skip this guide.
Copy link
Member

Choose a reason for hiding this comment

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

Just to double-check - is focus used for accessibility scenarios on mobile?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessarily: it's any app that can switch between traditional (key/mouse) input and touch input. @gspencergoog , did I read that right?

Copy link
Contributor

Choose a reason for hiding this comment

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

There's a separate thing for accessibility focus on mobile. They're different things.

There is focus on mobile, but only if you connect a bluetooth or USB keyboard and/or mouse and use it. If you switch between mouse and touch, the focus highlights will turn on and off depending on which you used last.

src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
: A sparse mirror of the widget tree that represents all the widgets
that can receive focus. The nodes in this tree are called _focus nodes_.

**Focus node**
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to mention somewhere here that focus nodes aren't widgets? Or do you think that the definition of focus tree makes that point?

src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
version of them.

### Best practices for creating FocusNode objects
This focus node exists at the farthest point from the root of the focus tree.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is false. You can give primary focus to an element (like a Card) which has descendants (like buttons) that don't have focus.

I'd just remove this sentence, or replace "focus tree" with "focus chain", where the primary focus is the end of the chain furthest from the root.

in the highlight mode.
To use a `FocusTraversalPolicy`, give one to a `FocusTraversalGroup`,
It determines the widget subtree in which the policy will be effective.
Avoid calling the member functions of the class directly.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't say "avoid". We try and not say that because people read that as "your app will crash if you do it wrong" and go through crazy hoops to never call it. Just say it's not typical.

src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
src/content/ui/interactivity/focus.md Outdated Show resolved Hide resolved
@parlough parlough added review.await-update Awaiting Updates after Edits and removed review.tech Awaiting Technical Review labels May 22, 2024
The other changes will be covered in a separate commit.

Co-authored-by: Greg Spencer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review.await-update Awaiting Updates after Edits
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'Understanding Flutter's keyboard focus system' needs tech and copy review
7 participants