@@ -170,7 +170,16 @@ class _ExampleEditorState extends State<ExampleEditor> {
170
170
// I tried explicitly unfocus()'ing the URL textfield
171
171
// in the toolbar but it didn't return focus to the
172
172
// editor. I'm not sure why.
173
- _editorFocusNode.requestFocus ();
173
+ //
174
+ // Only do that if the primary focus is not at the root focus scope because
175
+ // this might signify that the app is going to the background. Removing
176
+ // the focus from the root focus scope in that situation prevents the editor
177
+ // from re-gaining focus when the app is brought back to the foreground.
178
+ //
179
+ // See https://github.com/superlistapp/super_editor/issues/2279 for details.
180
+ if (FocusManager .instance.primaryFocus != FocusManager .instance.rootScope) {
181
+ _editorFocusNode.requestFocus ();
182
+ }
174
183
}
175
184
176
185
DocumentGestureMode get _gestureMode {
@@ -252,7 +261,16 @@ class _ExampleEditorState extends State<ExampleEditor> {
252
261
_imageFormatBarOverlayController.hide ();
253
262
254
263
// Ensure that focus returns to the editor.
255
- _editorFocusNode.requestFocus ();
264
+ //
265
+ // Only do that if the primary focus is not at the root focus scope because
266
+ // this might signify that the app is going to the background. Removing
267
+ // the focus from the root focus scope in that situation prevents the editor
268
+ // from re-gaining focus when the app is brought back to the foreground.
269
+ //
270
+ // See https://github.com/superlistapp/super_editor/issues/2279 for details.
271
+ if (FocusManager .instance.primaryFocus != FocusManager .instance.rootScope) {
272
+ _editorFocusNode.requestFocus ();
273
+ }
256
274
}
257
275
258
276
@override
0 commit comments