Esanders has uploaded a new change for review.
https://gerrit.wikimedia.org/r/193077
Change subject: Prevent context from moving if selection is changed by opening
......................................................................
Prevent context from moving if selection is changed by opening
Store the 'lastClosedSelection' whenever we update position and
the inspector isn't open, and use this when it is.
Bug: T90857
Change-Id: Ic0c479c34d415037ec0840661c4463941abefc9b
---
M src/ui/ve.ui.DesktopContext.js
1 file changed, 9 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor
refs/changes/77/193077/1
diff --git a/src/ui/ve.ui.DesktopContext.js b/src/ui/ve.ui.DesktopContext.js
index 004b58e..6eed2e2 100644
--- a/src/ui/ve.ui.DesktopContext.js
+++ b/src/ui/ve.ui.DesktopContext.js
@@ -22,6 +22,7 @@
this.popup = new OO.ui.PopupWidget( { $: this.$, $container:
this.surface.$element } );
this.transitioning = null;
this.suppressed = false;
+ this.lastClosedSelection = null;
this.onWindowResizeHandler = this.onPosition.bind( this );
this.$window = this.$( this.getElementWindow() );
@@ -201,11 +202,15 @@
* @inheritdoc
*/
ve.ui.DesktopContext.prototype.updateDimensions = function () {
- var startAndEndRects, position, embeddable, middle,
+ var startAndEndRects, position, embeddable, middle, boundingRect,
rtl = this.surface.getModel().getDocument().getDir() === 'rtl',
surface = this.surface.getView(),
- focusedNode = surface.getFocusedNode(),
- boundingRect = surface.getSelectionBoundingRect();
+ focusedNode = surface.getFocusedNode();
+
+ if ( !this.inspector || ( !this.inspector.isOpening() &&
!this.inspector.isOpened() ) ) {
+ this.lastClosedSelection =
surface.getModel().getSelection().clone();
+ }
+ boundingRect = surface.getSelectionBoundingRect(
this.lastClosedSelection );
if ( !boundingRect ) {
// If !boundingRect, the surface apparently isn't selected.
@@ -238,7 +243,7 @@
}
} else {
// The selection is text or an inline focused node
- startAndEndRects = surface.getSelectionStartAndEndRects();
+ startAndEndRects = surface.getSelectionStartAndEndRects(
this.lastClosedSelection );
if ( startAndEndRects ) {
middle = ( boundingRect.left + boundingRect.right ) / 2;
if (
--
To view, visit https://gerrit.wikimedia.org/r/193077
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic0c479c34d415037ec0840661c4463941abefc9b
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits