Skip to content

Conversation

@harperl-lgtm
Copy link
Contributor

This PR added optional labelText (which will be rendered side by side with Checkbox in the future, and thus is also announced by default by screen readers), and semanticLabel(which will be announced by screen reader if provided, overrides labelText, in order to do that we might want to wrap the Text widget inside ExcludeSemantics in the future).

Issues fixed:
[b/239564167]

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Dec 5, 2022
@harperl-lgtm harperl-lgtm requested a review from guidezpl December 5, 2022 22:57
Comment on lines 346 to 347
/// The label text that will be rendered side by side with the [Checkbox].
/// Serves as default semantics label for the [Checkbox] if provided.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// The label text that will be rendered side by side with the [Checkbox].
/// Serves as default semantics label for the [Checkbox] if provided.
/// The label text that will be rendered next to the [Checkbox].
///
/// If provided, serves as the default for [semanticLabel].

// TODO(harperl-lgtm): Actually render the labelText in build method.
final String? labelText;

/// The semantics label that will be announced by a screen reader.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// The semantics label that will be announced by a screen reader.
/// The semantic label that will be announced by screen readers.


/// The semantics label that will be announced by a screen reader.
///
/// Overrides labelText in terms of semantic labeling of the [Checkbox]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Overrides labelText in terms of semantic labeling of the [Checkbox]
/// Semantic label for the checkbox.
///
/// Announced in accessibility modes (e.g TalkBack/VoiceOver).
/// This label does not show in the UI.
///
/// Defaults to [labelText], if specified.

this.shape,
this.side,
this.isError = false,
this.labelText,
Copy link
Member

Choose a reason for hiding this comment

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

Let's avoid adding an unused property and save that for a future PR

@guidezpl guidezpl requested a review from darrenaustin December 8, 2022 14:06
@guidezpl
Copy link
Member

guidezpl commented Dec 8, 2022

@darrenaustin Was curious about your thoughts on the proposed TODO for this. CheckboxListTile is an overloaded widget for the simple case where text has to appear before or after a checkbox (and clicking that text toggles the checkbox).

@harperl-lgtm harperl-lgtm marked this pull request as ready for review December 8, 2022 18:55
Copy link
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

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

LGTM, with a couple of comments below. If an app already has a label that they have added themselves and wrapped the check box and label in a MergeSemantics, what happens with this new semanticLabel?

@darrenaustin
Copy link
Contributor

@darrenaustin Was curious about your thoughts on the proposed TODO for this. CheckboxListTile is an overloaded widget for the simple case where text has to appear before or after a checkbox (and clicking that text toggles the checkbox).

It sounds reasonable to me, but perhaps there was a reason we chose not to implement it with a label. @HansMuller do you have any opinion/context on this?

@HansMuller
Copy link
Contributor

HansMuller commented Dec 15, 2022

@darrenaustin Was curious about your thoughts on the proposed TODO for this. CheckboxListTile is an overloaded widget for the simple case where text has to appear before or after a checkbox (and clicking that text toggles the checkbox).

It sounds reasonable to me, but perhaps there was a reason we chose not to implement it with a label. @HansMuller do you have any opinion/context on this?

Long ago we decided not to make intrinsic labels a feature of components like Checkbox. Over time that gap has been filled in - for better or worse - by the FooListTile components. If the FooListTile component is inconvenient for a common case, then we should make it convenient, perhaps with a named constructor.

@harperl-lgtm
Copy link
Contributor Author

Thank you so much Hans for your insights! :D I agree it makes sense to pass a semantic label to a named constructor. Added in new commit!

@HansMuller
Copy link
Contributor

This looks good. Are you going to add a semanticLabel property to CheckboxListTile as well?

@HansMuller
Copy link
Contributor

I thought you'd just add a single semanticLabel constructor parameter to CheckboxListTile, I don't think the named constructor is needed (unless I'm missing something). I realize that I brought up FooListTile named constructors in #116551 (comment), but that suggestion assumed that an (unspecifed) common case was inconvenient. In this case, it seems like just passing the semanticLabel parameter through, from the CheckboxListTile to its Checkbox, would be sufficient and convenient.

@harperl-lgtm
Copy link
Contributor Author

I thought you'd just add a single semanticLabel constructor parameter to CheckboxListTile, I don't think the named constructor is needed (unless I'm missing something). I realize that I brought up FooListTile named constructors in #116551 (comment), but that suggestion assumed that an (unspecifed) common case was inconvenient. In this case, it seems like just passing the semanticLabel parameter through, from the CheckboxListTile to its Checkbox, would be sufficient and convenient.

I see. Thanks for clarifying Hans!! Constructor updated.

@harperl-lgtm
Copy link
Contributor Author

Looping in @Hangyujin who is going to take over some of my work. And thank you Hangyu for taking care of my PRs :)!

@hannah-hyj hannah-hyj self-assigned this Apr 4, 2023
@hannah-hyj
Copy link
Member

Closing this PR and reopen it int #124555 because the author is no longer working on this.

@hannah-hyj hannah-hyj closed this Apr 10, 2023
auto-submit bot pushed a commit that referenced this pull request Apr 14, 2023
Re-open from #116551

This PR added optional labelText (which will be  rendered side by side with Checkbox in the future, and thus is also announced by default by screen readers), and semanticLabel(which will be announced by screen reader if provided, overrides labelText, in order to do that we might want to wrap the Text widget inside ExcludeSemantics in the future).

Issues fixed:
[b/239564167]
exaby73 pushed a commit to exaby73/flutter_nevercode that referenced this pull request Apr 17, 2023
Re-open from flutter#116551

This PR added optional labelText (which will be  rendered side by side with Checkbox in the future, and thus is also announced by default by screen readers), and semanticLabel(which will be announced by screen reader if provided, overrides labelText, in order to do that we might want to wrap the Text widget inside ExcludeSemantics in the future).

Issues fixed:
[b/239564167]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants