Skip to content

ui: Include a tooltip with all our IconButtons #98

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

Merged
merged 2 commits into from
May 24, 2023

Conversation

chrisbobbe
Copy link
Collaborator

No description provided.

@chrisbobbe chrisbobbe requested a review from gnprice May 19, 2023 01:00
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM; one comment-only question, but feel free to merge.

Comment on lines +377 to +378
// M3-only params `isSelected` / `selectedIcon`, after fixing
// https://github.com/flutter/flutter/issues/127145 . (Also, the
Copy link
Member

Choose a reason for hiding this comment

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

Cool, good to have reported this. Looks like that issue was assigned just today, so hopefully will get fixed soon.

Comment on lines +378 to +381
// https://github.com/flutter/flutter/issues/127145 . (Also, the
// `Semantics` seen here would misbehave in M3 for reasons
// involving a `Semantics` with `container: true` in an underlying
// [ButtonStyleButton].)
Copy link
Member

Choose a reason for hiding this comment

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

Is there an issue to link to for this?

Copy link
Collaborator Author

@chrisbobbe chrisbobbe May 24, 2023

Choose a reason for hiding this comment

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

Good thought, but no, I don't think so. The change in behavior with M3 surprised me, but I haven't yet decided what upstream bug, if any, causes this Semantics to not do what we want. And as you saw, once flutter/flutter#127145 is fixed, we can remove the Semantics in M3 and get the right behavior, and that's good because it's nice and simple. 🙂

Here are some observations about what happens if I set useMaterial3: true near our app root:

IconButton builds something it calls _IconButtonM3, and that's a class that extends ButtonStyleButton. And ButtonStyleButton builds a Semantics with container: true, to introduce a new node in the Semantics tree (doc). I guess that could be a reasonable choice, I'm not sure. 🙂 I can focus the button with VoiceOver, and it just says: "Hide password. Button."—which means my toggled value is ignored. I found three separate ways I could fix the issue, to where it's still focusable and it says "Hide password. Switch button. On. Double-tap to toggle setting.". Those ways are:

If I copy this chunk of code (the one beginning with Semantics(toggled: _obscurePassword) to somewhere outside the password text field (say, between it and the "Log in" button), then the behaviors and fixes I've described replicate there too. I tested that because I noticed something odd happening near the original show/hide button: before applying one of the three fixes I listed above, a different focusable node would get the wrong text: the one for the whole password text field, before I drill down to (traverse forward to?) the show/hide button. VoiceOver would say, "Password. 1. Text field. Double-tap to edit"—or, for the show/hide button's other state, "Password. 0. Text field. Double-tap to edit". In that case, is the framework wanting to present suffixIcon as part of the meaning of the whole text field? (This code looks related…?) But here it's not meant as part of the text field's meaning; it's just a related control we offer.

We should probably always set `tooltip` on our IconButtons; it gives
context for users whether or not they're using screen-reader
software.
@chrisbobbe chrisbobbe force-pushed the pr-icon-button-tooltips branch from 4e08898 to dfe2695 Compare May 24, 2023 21:45
@chrisbobbe
Copy link
Collaborator Author

Thanks for the review! Merging, and I responded above: #98 (comment)

@chrisbobbe chrisbobbe merged commit dfe2695 into zulip:main May 24, 2023
@chrisbobbe chrisbobbe deleted the pr-icon-button-tooltips branch May 24, 2023 21:45
chrisbobbe added a commit to chrisbobbe/zulip-flutter that referenced this pull request May 26, 2023
Looks like I forgot to get this one in zulip#98, oops.
chrisbobbe added a commit that referenced this pull request May 31, 2023
Looks like I forgot to get this one in #98, oops.
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.

2 participants