Commit efc9463 1 parent 456990b commit efc9463 Copy full SHA for efc9463
File tree 1 file changed +15
-2
lines changed
modules/ensemble/lib/action
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ class ShowDialogAction extends EnsembleAction {
48
48
49
49
@override
50
50
Future execute (BuildContext context, ScopeManager scopeManager) {
51
+ // Save the currently focused widget so we can keep focus on it after dialog opens
52
+ FocusNode ? currentFocus = FocusManager .instance.primaryFocus;
51
53
// get styles. TODO: make bindable
52
54
Map <String , dynamic > dialogStyles = {};
53
55
options? .forEach ((key, value) {
@@ -109,10 +111,21 @@ class ShowDialogAction extends EnsembleAction {
109
111
useDefaultStyle ? const EdgeInsets .all (20 ) : null ,
110
112
child: DataScopeWidget (
111
113
scopeManager: scopeManager.createChildScope (),
112
- child: SingleChildScrollView (
114
+ child: Builder (
115
+ builder: (context) {
116
+ // Keep focus on the focus sensitive widgets (e.g. TextInput) after dialog opens
117
+ WidgetsBinding .instance.addPostFrameCallback ((_) {
118
+ if (currentFocus != null && currentFocus.hasFocus) {
119
+ currentFocus.requestFocus ();
120
+ }
121
+ });
122
+ return SingleChildScrollView (
113
123
child: scopeManager
114
124
.buildWidgetFromDefinition (body),
115
- ))))));
125
+ );
126
+ })))),
127
+ ),
128
+ );
116
129
}).then ((payload) {
117
130
// remove the dialog context since we are closing them
118
131
scopeManager.openedDialogs.remove (dialogContext);
You can’t perform that action at this time.
0 commit comments