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
ee274fde
Unverified
Commit
ee274fde
authored
May 31, 2022
by
Taha Tesser
Committed by
GitHub
May 31, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `showSearch` query text field doesn't show toolbar initially when field is empty. (#105023)
parent
c02be8cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletion
+39
-1
search.dart
packages/flutter/lib/src/material/search.dart
+3
-1
search_test.dart
packages/flutter/test/material/search_test.dart
+36
-0
No files found.
packages/flutter/lib/src/material/search.dart
View file @
ee274fde
...
...
@@ -263,7 +263,9 @@ abstract class SearchDelegate<T> {
set
query
(
String
value
)
{
assert
(
query
!=
null
);
_queryTextController
.
text
=
value
;
_queryTextController
.
selection
=
TextSelection
.
fromPosition
(
TextPosition
(
offset:
_queryTextController
.
text
.
length
));
if
(
_queryTextController
.
text
.
isNotEmpty
)
{
_queryTextController
.
selection
=
TextSelection
.
fromPosition
(
TextPosition
(
offset:
_queryTextController
.
text
.
length
));
}
}
/// Transition from the suggestions returned by [buildSuggestions] to the
...
...
packages/flutter/test/material/search_test.dart
View file @
ee274fde
...
...
@@ -883,6 +883,42 @@ void main() {
expect
(
rootObserver
.
pushCount
,
1
);
expect
(
localObserver
.
pushCount
,
1
);
});
testWidgets
(
'Query text field shows toolbar initially'
,
(
WidgetTester
tester
)
async
{
// This is a regression test for https://github.com/flutter/flutter/issues/95588
final
_TestSearchDelegate
delegate
=
_TestSearchDelegate
();
final
List
<
String
>
selectedResults
=
<
String
>[];
await
tester
.
pumpWidget
(
TestHomePage
(
delegate:
delegate
,
results:
selectedResults
,
));
// Open search.
await
tester
.
tap
(
find
.
byTooltip
(
'Search'
));
await
tester
.
pumpAndSettle
();
final
Finder
textFieldFinder
=
find
.
byType
(
TextField
);
final
TextField
textField
=
tester
.
widget
<
TextField
>(
textFieldFinder
);
expect
(
textField
.
controller
!.
text
.
length
,
0
);
mockClipboard
.
handleMethodCall
(
const
MethodCall
(
'Clipboard.setData'
,
<
String
,
dynamic
>{
'text'
:
'pasteablestring'
,
},
));
// Long press shows toolbar.
await
tester
.
longPress
(
textFieldFinder
);
await
tester
.
pump
();
expect
(
find
.
text
(
'Paste'
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'Paste'
));
await
tester
.
pump
();
expect
(
textField
.
controller
!.
text
.
length
,
15
);
},
skip:
kIsWeb
);
// [intended] We do not use Flutter-rendered context menu on the Web.
}
class
TestHomePage
extends
StatelessWidget
{
...
...
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