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
5533b90f
Unverified
Commit
5533b90f
authored
Mar 07, 2022
by
Markus Aksli
Committed by
GitHub
Mar 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-invoke DismissIntent in Autocomplete if ignored (#99403)
parent
436c3500
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
1 deletion
+62
-1
autocomplete.dart
packages/flutter/lib/src/widgets/autocomplete.dart
+3
-1
autocomplete_test.dart
packages/flutter/test/widgets/autocomplete_test.dart
+59
-0
No files found.
packages/flutter/lib/src/widgets/autocomplete.dart
View file @
5533b90f
...
...
@@ -370,11 +370,13 @@ class _RawAutocompleteState<T extends Object> extends State<RawAutocomplete<T>>
_updateHighlight
(
_highlightedOptionIndex
.
value
+
1
);
}
void
_hideOptions
(
DismissIntent
intent
)
{
Object
?
_hideOptions
(
DismissIntent
intent
)
{
if
(!
_userHidOptions
)
{
_userHidOptions
=
true
;
_updateOverlay
();
return
null
;
}
return
Actions
.
invoke
(
context
,
intent
);
}
void
_setActionsEnabled
(
bool
enabled
)
{
...
...
packages/flutter/test/widgets/autocomplete_test.dart
View file @
5533b90f
...
...
@@ -883,6 +883,65 @@ void main() {
expect
(
find
.
byKey
(
optionsKey
),
findsNothing
);
});
testWidgets
(
're-invokes DismissIntent if options not shown'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
fieldKey
=
GlobalKey
();
final
GlobalKey
optionsKey
=
GlobalKey
();
late
FocusNode
focusNode
;
bool
wrappingActionInvoked
=
false
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
Actions
(
actions:
<
Type
,
Action
<
Intent
>>{
DismissIntent:
CallbackAction
<
DismissIntent
>(
onInvoke:
(
_
)
=>
wrappingActionInvoked
=
true
,
),
},
child:
RawAutocomplete
<
String
>(
optionsBuilder:
(
TextEditingValue
textEditingValue
)
{
return
kOptions
.
where
((
String
option
)
{
return
option
.
contains
(
textEditingValue
.
text
.
toLowerCase
());
});
},
fieldViewBuilder:
(
BuildContext
context
,
TextEditingController
fieldTextEditingController
,
FocusNode
fieldFocusNode
,
VoidCallback
onFieldSubmitted
)
{
focusNode
=
fieldFocusNode
;
return
TextFormField
(
key:
fieldKey
,
focusNode:
focusNode
,
controller:
fieldTextEditingController
,
onFieldSubmitted:
(
String
value
)
{
onFieldSubmitted
();
},
);
},
optionsViewBuilder:
(
BuildContext
context
,
AutocompleteOnSelected
<
String
>
onSelected
,
Iterable
<
String
>
options
)
{
return
Container
(
key:
optionsKey
);
},
),
),
),
),
);
// Enter text to show options.
focusNode
.
requestFocus
();
await
tester
.
enterText
(
find
.
byKey
(
fieldKey
),
'ele'
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
byKey
(
fieldKey
),
findsOneWidget
);
expect
(
find
.
byKey
(
optionsKey
),
findsOneWidget
);
// Hide the options.
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
escape
);
await
tester
.
pump
();
expect
(
find
.
byKey
(
fieldKey
),
findsOneWidget
);
expect
(
find
.
byKey
(
optionsKey
),
findsNothing
);
expect
(
wrappingActionInvoked
,
false
);
// Ensure the wrapping Actions can receive the DismissIntent.
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
escape
);
expect
(
wrappingActionInvoked
,
true
);
});
testWidgets
(
'optionsViewBuilders can use AutocompleteHighlightedOption to highlight selected option'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
fieldKey
=
GlobalKey
();
final
GlobalKey
optionsKey
=
GlobalKey
();
...
...
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