Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
413c8a0b
Unverified
Commit
413c8a0b
authored
Mar 12, 2021
by
Jason Simmons
Committed by
GitHub
Mar 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not replace text with semantics labels in selectable text widgets (#77859)
parent
2530f4c5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
4 deletions
+34
-4
selectable_text.dart
packages/flutter/lib/src/material/selectable_text.dart
+1
-1
editable.dart
packages/flutter/lib/src/rendering/editable.dart
+2
-3
selectable_text_test.dart
packages/flutter/test/widgets/selectable_text_test.dart
+31
-0
No files found.
packages/flutter/lib/src/material/selectable_text.dart
View file @
413c8a0b
...
...
@@ -25,7 +25,7 @@ class _TextSpanEditingController extends TextEditingController {
_TextSpanEditingController
({
required
TextSpan
textSpan
}):
assert
(
textSpan
!=
null
),
_textSpan
=
textSpan
,
super
(
text:
textSpan
.
toPlainText
());
super
(
text:
textSpan
.
toPlainText
(
includeSemanticsLabels:
false
));
final
TextSpan
_textSpan
;
...
...
packages/flutter/lib/src/rendering/editable.dart
View file @
413c8a0b
...
...
@@ -1835,7 +1835,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
// Returns the obscured text when [obscureText] is true. See
// [obscureText] and [obscuringCharacter].
String
get
_plainText
{
_cachedPlainText
??=
_textPainter
.
text
!.
toPlainText
();
_cachedPlainText
??=
_textPainter
.
text
!.
toPlainText
(
includeSemanticsLabels:
false
);
return
_cachedPlainText
!;
}
...
...
@@ -2993,8 +2993,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
return
TextSelection
(
baseOffset:
0
,
extentOffset:
_plainText
.
length
);
// If the word is a space, on iOS try to select the previous word instead.
// On Android try to select the previous word instead only if the text is read only.
}
else
if
(
text
?.
toPlainText
()
!=
null
&&
_isWhitespace
(
text
!.
toPlainText
().
codeUnitAt
(
position
.
offset
))
}
else
if
(
_isWhitespace
(
_plainText
.
codeUnitAt
(
position
.
offset
))
&&
position
.
offset
>
0
)
{
assert
(
defaultTargetPlatform
!=
null
);
final
TextRange
?
previousWord
=
_getPreviousWord
(
word
.
start
);
...
...
packages/flutter/test/widgets/selectable_text_test.dart
View file @
413c8a0b
...
...
@@ -2866,6 +2866,37 @@ void main() {
expect
(
find
.
byType
(
CupertinoButton
),
findsNWidgets
(
1
));
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
,
TargetPlatform
.
macOS
}));
testWidgets
(
'double tap selects word with semantics label'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Material
(
child:
Center
(
child:
SelectableText
.
rich
(
TextSpan
(
text:
'Atwater Peel Sherbrooke Bonaventure'
,
semanticsLabel:
''
),
),
),
),
),
);
final
Offset
selectableTextStart
=
tester
.
getTopLeft
(
find
.
byType
(
SelectableText
));
await
tester
.
tapAt
(
selectableTextStart
+
const
Offset
(
220.0
,
5.0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
await
tester
.
tapAt
(
selectableTextStart
+
const
Offset
(
220.0
,
5.0
));
await
tester
.
pump
();
final
EditableText
editableTextWidget
=
tester
.
widget
(
find
.
byType
(
EditableText
).
first
);
final
TextEditingController
controller
=
editableTextWidget
.
controller
;
expect
(
controller
.
selection
,
const
TextSelection
(
baseOffset:
13
,
extentOffset:
23
),
);
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
,
TargetPlatform
.
macOS
}));
testWidgets
(
'tap after a double tap select is not affected (iOS)'
,
(
WidgetTester
tester
)
async
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment