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
f5cecd04
Unverified
Commit
f5cecd04
authored
Aug 04, 2022
by
hangyu
Committed by
GitHub
Aug 04, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix an issue that semantics on TextField is not updated when changing obscureText (#108545)
parent
a733b54d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
0 deletions
+92
-0
editable.dart
packages/flutter/lib/src/rendering/editable.dart
+1
-0
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+91
-0
No files found.
packages/flutter/lib/src/rendering/editable.dart
View file @
f5cecd04
...
...
@@ -589,6 +589,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
return
;
}
_obscureText
=
value
;
_cachedAttributedValue
=
null
;
markNeedsSemanticsUpdate
();
}
...
...
packages/flutter/test/material/text_field_test.dart
View file @
f5cecd04
...
...
@@ -6119,6 +6119,60 @@ void main() {
semantics
.
dispose
();
});
// Regressing test for https://github.com/flutter/flutter/issues/99763
testWidgets
(
'Update textField semantics when obscureText changes'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
final
TextEditingController
controller
=
TextEditingController
();
await
tester
.
pumpWidget
(
_ObscureTextTestWidget
(
controller:
controller
));
controller
.
text
=
'Hello'
;
await
tester
.
pump
();
expect
(
semantics
,
includesNodeWith
(
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
textDirection:
TextDirection
.
ltr
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isTextField
,
],
value:
'Hello'
,
)
);
await
tester
.
tap
(
find
.
byType
(
ElevatedButton
));
await
tester
.
pump
();
expect
(
semantics
,
includesNodeWith
(
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
textDirection:
TextDirection
.
ltr
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isTextField
,
SemanticsFlag
.
isObscured
,
],
)
);
await
tester
.
tap
(
find
.
byType
(
ElevatedButton
));
await
tester
.
pump
();
expect
(
semantics
,
includesNodeWith
(
actions:
<
SemanticsAction
>[
SemanticsAction
.
tap
],
textDirection:
TextDirection
.
ltr
,
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isTextField
,
],
value:
'Hello'
,
)
);
semantics
.
dispose
();
});
testWidgets
(
'TextField semantics, enableInteractiveSelection = false'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
final
TextEditingController
controller
=
TextEditingController
();
...
...
@@ -12204,3 +12258,40 @@ void main() {
});
});
}
/// A Simple widget for testing the obscure text.
class
_ObscureTextTestWidget
extends
StatefulWidget
{
const
_ObscureTextTestWidget
({
required
this
.
controller
});
final
TextEditingController
controller
;
@override
_ObscureTextTestWidgetState
createState
()
=>
_ObscureTextTestWidgetState
();
}
class
_ObscureTextTestWidgetState
extends
State
<
_ObscureTextTestWidget
>
{
bool
_obscureText
=
false
;
@override
Widget
build
(
BuildContext
context
)
{
return
MaterialApp
(
home:
Scaffold
(
body:
Builder
(
builder:
(
_
)
{
return
Column
(
children:
<
Widget
>[
TextField
(
obscureText:
_obscureText
,
controller:
widget
.
controller
,
),
ElevatedButton
(
onPressed:
()
=>
setState
(()
{
_obscureText
=
!
_obscureText
;}),
child:
const
SizedBox
.
shrink
(),
),
],
);
},
),
),
);
}
}
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