Catrope has uploaded a new change for review. https://gerrit.wikimedia.org/r/98116
Change subject: Close inspectors when surface is focused but selection doesn't change ...................................................................... Close inspectors when surface is focused but selection doesn't change It's possible for the user to put the cursor back from the inspector in the surface without triggering a selection change, if the selection was collapsed and they clicked in exactly the right spot. In practice, this can happen if the link inspector is open in creation mode and the user clicks to drop the cursor at the same position where it was when the inspector was opened. When this happens, the inspector wouldn't close, because it only closed in response to selection changes. If the user then typed something, weird things would happen. To prevent this state (cursor is in surface but inspector is open) from occurring, close the inspector and hide the context when the document is focused. This fixes the link inspector creation mode issue, and it also causes the link inspector to no longer briefly remain visible after the user has clicked out of it. Bug: 56976 Change-Id: Ib70fc13031873009a175e4b049a07694a87ce25d --- M modules/ve/ui/ve.ui.Context.js 1 file changed, 23 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/16/98116/1 diff --git a/modules/ve/ui/ve.ui.Context.js b/modules/ve/ui/ve.ui.Context.js index cb5d6cb..7099fc2 100644 --- a/modules/ve/ui/ve.ui.Context.js +++ b/modules/ve/ui/ve.ui.Context.js @@ -54,7 +54,8 @@ 'selectionStart': 'onSelectionStart', 'selectionEnd': 'onSelectionEnd', 'relocationStart': 'onRelocationStart', - 'relocationEnd': 'onRelocationEnd' + 'relocationEnd': 'onRelocationEnd', + 'focus': 'onSurfaceFocus' } ); this.inspectors.connect( this, { 'opening': 'onInspectorOpening', @@ -120,6 +121,27 @@ }; /** + * Respond to focus events on the surfaceView by hiding the context. + * + * If there's an inspector open and the user manages to drop the cursor in the surface such that + * the selection doesn't change (i.e. the resulting model selection is equal to the previous model + * selection), then #onModelSelect won't cause the inspector to be closed, so we do that here. + * + * Hiding the context immediately on focus also avoids flickering phenomena where the inspector + * remains open or the context remains visible in the wrong place while the selection is visually + * already moving somewhere else. We deliberately don't call #update to avoid drawing the context + * in a place that the selection is about to move away from. + * + * We don't have to defer the response to this event because there is no danger that inspectors' + * close handlers will end up invoking this handler again. + */ +ve.ui.Context.prototype.onSurfaceFocus = function () { + if ( this.popup.isVisible() ) { + this.hide(); + } +}; + +/** * Handle selection start events on the view. * * @method -- To view, visit https://gerrit.wikimedia.org/r/98116 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib70fc13031873009a175e4b049a07694a87ce25d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Catrope <roan.katt...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits