Trevor Parscal has uploaded a new change for review.

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

Change subject: Update context menu on document update
......................................................................

Update context menu on document update

This way a context item that triggers a dialog will still get updated (if 
needed) when the dialog closes.

Bug: T91336
Change-Id: I6cce684842385a82a359c8bac7e63222e96d08c2
---
M src/ui/ve.ui.Context.js
1 file changed, 16 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/60/197960/1

diff --git a/src/ui/ve.ui.Context.js b/src/ui/ve.ui.Context.js
index ddf694d..f1bf98a 100644
--- a/src/ui/ve.ui.Context.js
+++ b/src/ui/ve.ui.Context.js
@@ -35,7 +35,10 @@
        this.updateDimensionsDebounced = ve.debounce( 
this.updateDimensions.bind( this ) );
 
        // Events
-       this.surface.getModel().connect( this, { contextChange: 
'onContextChange' } );
+       this.surface.getModel().connect( this, {
+               contextChange: 'onContextChange',
+               documentUpdate: 'onDocumentUpdate'
+       } );
        this.inspectors.connect( this, { opening: 'onInspectorOpening' } );
 
        // Initialization
@@ -97,6 +100,17 @@
        }
        // Purge related items cache
        this.relatedSources = null;
+};
+
+/**
+ * Handle document update event.
+ */
+ve.ui.Context.prototype.onDocumentUpdate = function () {
+       // Only mind this event if the menu is visible
+       if ( this.isVisible() && !this.isEmpty() ) {
+               // Reuse the debounced context change hanlder
+               this.onContextChange();
+       }
 };
 
 /**
@@ -341,6 +355,7 @@
  * @chainable
  */
 ve.ui.Context.prototype.setupMenuItems = function () {
+       console.log( 'setup' );
        var i, len, source,
                sources = this.getRelatedSources(),
                items = [];

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6cce684842385a82a359c8bac7e63222e96d08c2
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Trevor Parscal <[email protected]>

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

Reply via email to