Unverified Commit b129fffa authored by Pierre-Louis's avatar Pierre-Louis Committed by GitHub

Add `semanticsLabel` to `SelectableText` (#89369)

* add `semanticsLabel` to `SelectableText`

* remove unused vars

* Squashed commit of the following:

commit 3e687a9f
Author: engine-flutter-autoroll <engine-flutter-autoroll@skia.org>
Date:   Tue Sep 14 17:42:05 2021 -0400

    Roll Plugins from 4a98e239b131 to b85edebe7134 (2 revisions) (#90083)

commit ad936b4e
Author: Christopher Fujino <christopherfujino@gmail.com>
Date:   Tue Sep 14 14:39:17 2021 -0700

    [flutter_conductor] Support initial stable release version (#89775)

commit ff5dd54c
Author: Ian Hickson <ian@hixie.ch>
Date:   Tue Sep 14 13:02:04 2021 -0700

    Mention the ToS on our README (#89765)

commit 8587b609
Author: Kate Lovett <katelovett@google.com>
Date:   Tue Sep 14 14:53:33 2021 -0500

    Update local gold api (#90072)

commit 7d368dcf
Author: Justin McCandless <jmccandless@google.com>
Date:   Tue Sep 14 12:39:19 2021 -0700

    InteractiveViewer with a child of zero size (#90012)

    Asserts that the InteractiveViewer child can't have zero size.

commit 2b4ef184
Author: Akira Aratani <developer.a.akira@gmail.com>
Date:   Wed Sep 15 03:30:50 2021 +0900

    Fix document of the switch. (#89641)

commit a2cd16ba
Author: Christopher Fujino <christopherfujino@gmail.com>
Date:   Tue Sep 14 11:22:02 2021 -0700

    use test logger, which does not allow colors (#90010)

commit 0f0613c0
Author: Varun Sharma <varunsh@stepsecurity.io>
Date:   Tue Sep 14 11:17:03 2021 -0700

    Add specific permissions to .github/workflows/lock.yaml (#89820)

commit 2866f79c
Author: Jason Simmons <jason-simmons@users.noreply.github.com>
Date:   Tue Sep 14 10:46:35 2021 -0700

    Initialize all bindings before starting the text_editing_action_target test suite (#90067)

    Fixes https://github.com/flutter/flutter/issues/90057

commit b8899159
Author: Michael Thomsen <mit@google.com>
Date:   Tue Sep 14 14:08:36 2021 +0200

    Change min Dart SDK constraint to track actual version (#88743)

commit 3b7adb98
Author: godofredoc <54371434+godofredoc@users.noreply.github.com>
Date:   Mon Sep 13 21:32:04 2021 -0700

    Lock only issues. (#90023)

commit 528f77dc
Author: Dan Field <dnfield@google.com>
Date:   Mon Sep 13 19:10:15 2021 -0700

    Opacity fix (#90017)

    * Make sure Opacity widgets/layers do not drop the offset

commit 2470f63e
Author: engine-flutter-autoroll <engine-flutter-autoroll@skia.org>
Date:   Mon Sep 13 22:07:02 2021 -0400

    4a98e239b [flutter_plugin_tools] Make no unit tests fatal for iOS/macOS (flutter/plugins#4341) (#90016)

commit a01e4733
Author: stuartmorgan <stuartmorgan@google.com>
Date:   Mon Sep 13 20:57:05 2021 -0400

    Re-enable plugin analysis test (#89856)

commit cdad35f2
Author: Aneesh Rao <sidrao2006@gmail.com>
Date:   Tue Sep 14 05:17:04 2021 +0530

    Fix path in example (#84707)

commit 576aab08
Author: Christopher Fujino <christopherfujino@gmail.com>
Date:   Mon Sep 13 15:47:03 2021 -0700

    add analysis_options.yaml to dev/conductor (#90005)

commit fad5e4cf
Author: Jason Simmons <jason-simmons@users.noreply.github.com>
Date:   Mon Sep 13 13:37:07 2021 -0700

    Remove a redundant test case in the flutter_tools create_test (#89872)

commit 738430ca
Author: Darren Austin <darrenaustin@google.com>
Date:   Mon Sep 13 13:33:48 2021 -0700

    Revert "Removed default page transitions for desktop and web platforms. (#82596)" (#89997)

    This reverts commit 43e31977

commit 9db9256b
Author: Dan Field <dnfield@google.com>
Date:   Mon Sep 13 13:15:19 2021 -0700

    Revert "Make sure Opacity widgets/layers do not drop the offset (#89264)" (#89999)

    This reverts commit 0d0f7a4f.

commit 00f78cf2
Author: keyonghan <54558023+keyonghan@users.noreply.github.com>
Date:   Mon Sep 13 13:04:01 2021 -0700

    renew cirrus key (#89988)

commit 826da7f8
Author: engine-flutter-autoroll <engine-flutter-autoroll@skia.org>
Date:   Mon Sep 13 15:52:03 2021 -0400

    cfc8a20a1 renew cirrus key (flutter/plugins#4340) (#89996)

commit cd112e55
Author: Anna Gringauze <annagrin@google.com>
Date:   Mon Sep 13 12:13:42 2021 -0700

    Update all packages (#89797)
parent bcb5db77
......@@ -198,6 +198,7 @@ class SelectableText extends StatefulWidget {
this.selectionControls,
this.onTap,
this.scrollPhysics,
this.semanticsLabel,
this.textHeightBehavior,
this.textWidthBasis,
this.onSelectionChanged,
......@@ -255,6 +256,7 @@ class SelectableText extends StatefulWidget {
this.selectionControls,
this.onTap,
this.scrollPhysics,
this.semanticsLabel,
this.textHeightBehavior,
this.textWidthBasis,
this.onSelectionChanged,
......@@ -409,6 +411,9 @@ class SelectableText extends StatefulWidget {
/// {@macro flutter.widgets.editableText.scrollPhysics}
final ScrollPhysics? scrollPhysics;
/// {@macro flutter.widgets.Text.semanticsLabel}
final String? semanticsLabel;
/// {@macro flutter.dart:ui.textHeightBehavior}
final TextHeightBehavior? textHeightBehavior;
......@@ -425,6 +430,7 @@ class SelectableText extends StatefulWidget {
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<String>('data', data, defaultValue: null));
properties.add(DiagnosticsProperty<String>('semanticsLabel', semanticsLabel, defaultValue: null));
properties.add(DiagnosticsProperty<FocusNode>('focusNode', focusNode, defaultValue: null));
properties.add(DiagnosticsProperty<TextStyle>('style', style, defaultValue: null));
properties.add(DiagnosticsProperty<bool>('autofocus', autofocus, defaultValue: false));
......@@ -697,6 +703,7 @@ class _SelectableTextState extends State<SelectableText> with AutomaticKeepAlive
);
return Semantics(
label: widget.semanticsLabel,
onLongPress: () {
_effectiveFocusNode.requestFocus();
},
......
......@@ -494,6 +494,7 @@ class Text extends StatelessWidget {
/// widget directly to entirely override the [DefaultTextStyle].
final int? maxLines;
/// {@template flutter.widgets.Text.semanticsLabel}
/// An alternative semantics label for this text.
///
/// If present, the semantics of this widget will contain this value instead
......@@ -506,6 +507,7 @@ class Text extends StatelessWidget {
/// ```dart
/// Text(r'$$', semanticsLabel: 'Double dollars')
/// ```
/// {@endtemplate}
final String? semanticsLabel;
/// {@macro flutter.painting.textPainter.textWidthBasis}
......
......@@ -2235,6 +2235,40 @@ void main() {
semantics.dispose();
});
testWidgets('SelectableText semantics, with semanticsLabel', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final Key key = UniqueKey();
await tester.pumpWidget(
overlay(
child: SelectableText(
'Guten Tag',
semanticsLabel: 'German greeting for good day',
key: key,
),
),
);
expect(semantics, hasSemantics(TestSemantics.root(
children: <TestSemantics>[
TestSemantics.rootChild(
id: 1,
textDirection: TextDirection.ltr,
label: 'German greeting for good day',
value: 'Guten Tag',
actions: <SemanticsAction>[
SemanticsAction.longPress,
],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.isReadOnly,
SemanticsFlag.isMultiline,
],
),
],
), ignoreTransform: true, ignoreRect: true));
});
testWidgets('SelectableText semantics, enableInteractiveSelection = false', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final Key key = UniqueKey();
......@@ -3850,6 +3884,7 @@ void main() {
cursorRadius: Radius.zero,
cursorColor: Color(0xff00ff00),
scrollPhysics: ClampingScrollPhysics(),
semanticsLabel: 'something else',
enableInteractiveSelection: false,
).debugFillProperties(builder);
......@@ -3859,6 +3894,7 @@ void main() {
expect(description, <String>[
'data: something',
'semanticsLabel: something else',
'style: TextStyle(inherit: true, color: Color(0xff00ff00))',
'autofocus: true',
'showCursor: true',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment