Catrope has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/231405

Change subject: Fix editor focusing issues
......................................................................

Fix editor focusing issues

* Autofocus needs to be evaluated before the switching promise is
  resolved (so callers can enable/disable autofocus after a switch)
  but executed after the switching promise is resolved (so callers
  that disable the editor while the promise is pending don't break)
* BoardDescriptionWidget makes itself pending (and disabled) for
  a longer period of time, so it needs to manually focus the editor
  when it un-disables it

Bug: T97290
Change-Id: Ic0fffc61a61503a7ceca714bfcb5e939c1966ec4
---
M handlebars/compiled/flow_block_header.handlebars.php
M modules/flow/ui/widgets/editor/mw.flow.ui.EditorSwitcherWidget.js
M modules/flow/ui/widgets/mw.flow.ui.BoardDescriptionWidget.js
3 files changed, 10 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/05/231405/1

diff --git a/handlebars/compiled/flow_block_header.handlebars.php 
b/handlebars/compiled/flow_block_header.handlebars.php
index cb753d6..686f174 100644
--- a/handlebars/compiled/flow_block_header.handlebars.php
+++ b/handlebars/compiled/flow_block_header.handlebars.php
@@ -82,4 +82,4 @@
 '.LCRun3::p($cx, 'flow_header_title', array(array($in),array()), '     
').''.LCRun3::p($cx, 'flow_errors', array(array($in),array()), '        
').''.((LCRun3::ifvar($cx, ((isset($in['oldSystem']) && is_array($in)) ? 
$in['oldSystem'] : null))) ? ''.LCRun3::p($cx, 'flow_header_detail_oldsystem', 
array(array($in),array()), '            ').'' : ''.LCRun3::p($cx, 
'flow_header_detail', array(array($in),array()), '            
').'').''.LCRun3::p($cx, 'flow_header_footer', array(array($in),array()), '     
').'</div>
 ';
 }
-?>
+?>
\ No newline at end of file
diff --git a/modules/flow/ui/widgets/editor/mw.flow.ui.EditorSwitcherWidget.js 
b/modules/flow/ui/widgets/editor/mw.flow.ui.EditorSwitcherWidget.js
index 0efbb80..4a2c8e4 100644
--- a/modules/flow/ui/widgets/editor/mw.flow.ui.EditorSwitcherWidget.js
+++ b/modules/flow/ui/widgets/editor/mw.flow.ui.EditorSwitcherWidget.js
@@ -240,6 +240,9 @@
                                }
                        } )
                        .then( function () {
+                               // Check .autoFocus now, in case handlers for 
switchingDeferred change it
+                               var shouldFocus = widget.autoFocus;
+
                                widget.activeEditorName = name;
                                widget.contentFormat = newFormat;
 
@@ -250,12 +253,13 @@
                                widget.$element.append( newEditor.$element );
 
                                newEditor.toggle( true );
-                               if ( widget.autoFocus ) {
-                                       newEditor.focus();
-                               }
 
                                switchingDeferred.resolve();
                                widget.switchingPromise = null;
+
+                               if ( shouldFocus ) {
+                                       newEditor.focus();
+                               }
                        } )
                        .fail( function ( error ) {
                                widget.activeEditorName = oldName;
diff --git a/modules/flow/ui/widgets/mw.flow.ui.BoardDescriptionWidget.js 
b/modules/flow/ui/widgets/mw.flow.ui.BoardDescriptionWidget.js
index ee0c970..980e663 100644
--- a/modules/flow/ui/widgets/mw.flow.ui.BoardDescriptionWidget.js
+++ b/modules/flow/ui/widgets/mw.flow.ui.BoardDescriptionWidget.js
@@ -130,6 +130,8 @@
                        .always( function () {
                                // Unset pending editor
                                widget.editor.popPending();
+                               // Focus again: pending editors are disabled 
and can't be focused
+                               widget.editor.focus();
                        } );
 
        };

-- 
To view, visit https://gerrit.wikimedia.org/r/231405
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic0fffc61a61503a7ceca714bfcb5e939c1966ec4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to