jenkins-bot has submitted this change and it was merged.
Change subject: Correctly handle activating an editor the second time
......................................................................
Correctly handle activating an editor the second time
* Don't switch back to the preferred editor when activating
an already active editor
* Focus the editor when activating it the second time
* In BoardDescriptionWidget, don't repopulate the editor when
activating it the second time
Change-Id: Iefd76d56a147cae2755c8358143febf49e29fdcf
---
M modules/flow/ui/widgets/editor/mw.flow.ui.EditorSwitcherWidget.js
M modules/flow/ui/widgets/editor/mw.flow.ui.EditorWidget.js
M modules/flow/ui/widgets/mw.flow.ui.BoardDescriptionWidget.js
M modules/flow/ui/widgets/mw.flow.ui.ReplyWidget.js
4 files changed, 32 insertions(+), 3 deletions(-)
Approvals:
Sbisson: Looks good to me, approved
jenkins-bot: Verified
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 8572347..1e24a9c 100644
--- a/modules/flow/ui/widgets/editor/mw.flow.ui.EditorSwitcherWidget.js
+++ b/modules/flow/ui/widgets/editor/mw.flow.ui.EditorSwitcherWidget.js
@@ -127,6 +127,15 @@
};
/**
+ * Check whether an editor is currently active. This returns false
before the first editor
+ * is loaded, and true after that. It also returns true if and editor
switch is in progress.
+ * @return {boolean} Editor is active
+ */
+ mw.flow.ui.EditorSwitcherWidget.prototype.isActive = function () {
+ return !!this.activeEditorName || !!this.switchingPromise;
+ };
+
+ /**
* Get the next editor after the currently active one.
* @return {string} Name of the next editor
*/
diff --git a/modules/flow/ui/widgets/editor/mw.flow.ui.EditorWidget.js
b/modules/flow/ui/widgets/editor/mw.flow.ui.EditorWidget.js
index 6bfc389..aa2cadc 100644
--- a/modules/flow/ui/widgets/editor/mw.flow.ui.EditorWidget.js
+++ b/modules/flow/ui/widgets/editor/mw.flow.ui.EditorWidget.js
@@ -99,6 +99,15 @@
// merge EditorSwitcherWidget into EditorWidget?
/**
+ * Check whether an editor is currently active. This returns false
before the first editor
+ * is loaded, and true after that. It also returns true if and editor
switch is in progress.
+ * @return {boolean} Editor is active
+ */
+ mw.flow.ui.EditorWidget.prototype.isActive = function () {
+ return this.editorSwitcherWidget.isActive();
+ };
+
+ /**
* Get the content of the editor.
* @return {string|null} Content of the editor, or null if no editor is
active.
*/
@@ -167,11 +176,15 @@
};
/**
- * Activate the switcher
+ * Activate the first editor, if not already active.
* @return {jQuery.Promise} Promise resolved when editor switch is done
*/
mw.flow.ui.EditorWidget.prototype.activate = function () {
- // Doesn't call editorSwitcherWdiget.activate() because we want
to
+ if ( this.isActive() ) {
+ return $.Deferred().resolve().promise();
+ }
+
+ // Doesn't call editorSwitcherWidget.activate() because we want
to
// evaluate the user preference as late as possible
return this.editorSwitcherWidget.switchEditor(
this.initialEditor || mw.user.options.get(
'flow-editor' )
diff --git a/modules/flow/ui/widgets/mw.flow.ui.BoardDescriptionWidget.js
b/modules/flow/ui/widgets/mw.flow.ui.BoardDescriptionWidget.js
index 980e663..e788dd0 100644
--- a/modules/flow/ui/widgets/mw.flow.ui.BoardDescriptionWidget.js
+++ b/modules/flow/ui/widgets/mw.flow.ui.BoardDescriptionWidget.js
@@ -101,9 +101,14 @@
this.error.toggle( false );
this.$content.addClass( 'oo-ui-element-hidden' );
+ this.editor.toggle( true );
+ if ( this.editor.isActive() ) {
+ this.editor.focus();
+ return;
+ }
+
// Load the editor
this.editor.pushPending();
- this.editor.toggle( true );
this.anonWarning.toggle( true );
this.editor.activate();
diff --git a/modules/flow/ui/widgets/mw.flow.ui.ReplyWidget.js
b/modules/flow/ui/widgets/mw.flow.ui.ReplyWidget.js
index b04bedf..5279c71 100644
--- a/modules/flow/ui/widgets/mw.flow.ui.ReplyWidget.js
+++ b/modules/flow/ui/widgets/mw.flow.ui.ReplyWidget.js
@@ -155,6 +155,8 @@
this.anonWarning.toggle( true );
this.editor.toggle( true );
this.editor.activate();
+ // If the editor was already active, focus it
+ this.editor.focus();
this.expanded = true;
};
--
To view, visit https://gerrit.wikimedia.org/r/231480
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iefd76d56a147cae2755c8358143febf49e29fdcf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits