From b129fffa2350d099a2ce37afec0e2c2b47434b97 Mon Sep 17 00:00:00 2001 From: Pierre-Louis <6655696+guidezpl@users.noreply.github.com> Date: Wed, 15 Sep 2021 11:51:47 +0200 Subject: [PATCH] Add `semanticsLabel` to `SelectableText` (#89369) * add `semanticsLabel` to `SelectableText` * remove unused vars * Squashed commit of the following: commit 3e687a9facfba751667529dd10194403c85e3d2f Author: engine-flutter-autoroll Date: Tue Sep 14 17:42:05 2021 -0400 Roll Plugins from 4a98e239b131 to b85edebe7134 (2 revisions) (#90083) commit ad936b4e4b778dde40b6adfea265b5f97f76f62d Author: Christopher Fujino Date: Tue Sep 14 14:39:17 2021 -0700 [flutter_conductor] Support initial stable release version (#89775) commit ff5dd54c6e2314e358d2e75d9c2c4fe24ed466d7 Author: Ian Hickson Date: Tue Sep 14 13:02:04 2021 -0700 Mention the ToS on our README (#89765) commit 8587b609a6b2cd253c9718c61fdebf89a2039169 Author: Kate Lovett Date: Tue Sep 14 14:53:33 2021 -0500 Update local gold api (#90072) commit 7d368dcf0c00b45fef5b02c5cccb8aa5306234ba Author: Justin McCandless 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 2b4ef184b7217bdc34e5b382398bc9077f748150 Author: Akira Aratani Date: Wed Sep 15 03:30:50 2021 +0900 Fix document of the switch. (#89641) commit a2cd16ba826cb8708f5b2ded9c99c6aa200551d9 Author: Christopher Fujino Date: Tue Sep 14 11:22:02 2021 -0700 use test logger, which does not allow colors (#90010) commit 0f0613c0aee159ff2089b4ce788744f8cbe46c3a Author: Varun Sharma Date: Tue Sep 14 11:17:03 2021 -0700 Add specific permissions to .github/workflows/lock.yaml (#89820) commit 2866f79c89e9540595727481b51c783dc65e8bbe Author: Jason Simmons 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 b889915997df2ad9f4329b7caba1eee6b2c53b31 Author: Michael Thomsen Date: Tue Sep 14 14:08:36 2021 +0200 Change min Dart SDK constraint to track actual version (#88743) commit 3b7adb989fc59fd6aa906ee642d749b26f1a4b29 Author: godofredoc <54371434+godofredoc@users.noreply.github.com> Date: Mon Sep 13 21:32:04 2021 -0700 Lock only issues. (#90023) commit 528f77dc99e43f3eb20698cb683c25705725ced0 Author: Dan Field Date: Mon Sep 13 19:10:15 2021 -0700 Opacity fix (#90017) * Make sure Opacity widgets/layers do not drop the offset commit 2470f63ebba59ebdd9a7127a7c51c22471f3b1d7 Author: engine-flutter-autoroll 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 a01e4733df822f641fb017f3d6d4c56de7427f5d Author: stuartmorgan Date: Mon Sep 13 20:57:05 2021 -0400 Re-enable plugin analysis test (#89856) commit cdad35f2d87f2684d6b651d8db17e938d3570d8a Author: Aneesh Rao Date: Tue Sep 14 05:17:04 2021 +0530 Fix path in example (#84707) commit 576aab08334e9f7989b32620cdc6b58d31162111 Author: Christopher Fujino Date: Mon Sep 13 15:47:03 2021 -0700 add analysis_options.yaml to dev/conductor (#90005) commit fad5e4cf892bcf65ad3f1cde092cfb9671c3de99 Author: Jason Simmons Date: Mon Sep 13 13:37:07 2021 -0700 Remove a redundant test case in the flutter_tools create_test (#89872) commit 738430cad787543bd815beb256acf29161771d92 Author: Darren Austin 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 9db9256b38ea33641b7bc02b537501ccde3a9957 Author: Dan Field 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 0d0f7a4fb065da5de8640f1d6757cd5b9bc5534b. commit 00f78cf263066dedaa5cddfccb9e8c4d620abe13 Author: keyonghan <54558023+keyonghan@users.noreply.github.com> Date: Mon Sep 13 13:04:01 2021 -0700 renew cirrus key (#89988) commit 826da7f82665c37a10dd3281e66dd14a205dc42d Author: engine-flutter-autoroll Date: Mon Sep 13 15:52:03 2021 -0400 cfc8a20a1 renew cirrus key (flutter/plugins#4340) (#89996) commit cd112e551c6a49434e30bd375e28144ab739c7a3 Author: Anna Gringauze Date: Mon Sep 13 12:13:42 2021 -0700 Update all packages (#89797) --- .../lib/src/material/selectable_text.dart | 7 ++++ packages/flutter/lib/src/widgets/text.dart | 2 ++ .../test/widgets/selectable_text_test.dart | 36 +++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/packages/flutter/lib/src/material/selectable_text.dart b/packages/flutter/lib/src/material/selectable_text.dart index 21e0667ea85..943050c7bc7 100644 --- a/packages/flutter/lib/src/material/selectable_text.dart +++ b/packages/flutter/lib/src/material/selectable_text.dart @@ -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('data', data, defaultValue: null)); + properties.add(DiagnosticsProperty('semanticsLabel', semanticsLabel, defaultValue: null)); properties.add(DiagnosticsProperty('focusNode', focusNode, defaultValue: null)); properties.add(DiagnosticsProperty('style', style, defaultValue: null)); properties.add(DiagnosticsProperty('autofocus', autofocus, defaultValue: false)); @@ -697,6 +703,7 @@ class _SelectableTextState extends State with AutomaticKeepAlive ); return Semantics( + label: widget.semanticsLabel, onLongPress: () { _effectiveFocusNode.requestFocus(); }, diff --git a/packages/flutter/lib/src/widgets/text.dart b/packages/flutter/lib/src/widgets/text.dart index 7b32b088ecd..6b3f20d22db 100644 --- a/packages/flutter/lib/src/widgets/text.dart +++ b/packages/flutter/lib/src/widgets/text.dart @@ -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} diff --git a/packages/flutter/test/widgets/selectable_text_test.dart b/packages/flutter/test/widgets/selectable_text_test.dart index 03e0870f902..03781420746 100644 --- a/packages/flutter/test/widgets/selectable_text_test.dart +++ b/packages/flutter/test/widgets/selectable_text_test.dart @@ -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.rootChild( + id: 1, + textDirection: TextDirection.ltr, + label: 'German greeting for good day', + value: 'Guten Tag', + actions: [ + SemanticsAction.longPress, + ], + flags: [ + 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, [ 'data: something', + 'semanticsLabel: something else', 'style: TextStyle(inherit: true, color: Color(0xff00ff00))', 'autofocus: true', 'showCursor: true',