Daniel Werner has submitted this change and it was merged.
Change subject: (hotfix) Fix for broken snakview key handling
..
(hotfix) Fix for broken snakview key handling
The native snakview stopediting event needs to be cut off in claimview
and snalistview by default.
Change-Id: Iae0160abc38a1c842ff2ead3fbd8f24aa8a6bfe6
---
M lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
M lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js
2 files changed, 23 insertions(+), 3 deletions(-)
Approvals:
Daniel Werner: Verified; Looks good to me, approved
jenkins-bot: Checked
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
b/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
index 3544c4b..edefed6 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
@@ -335,13 +335,21 @@
_attachEditModeEventHandlers: function() {
var self = this;
- this.$mainSnak.one( 'snakviewstopediting', function( event,
dropValue ) {
+ function defaultHandling( event, dropValue ) {
+ event.stopImmediatePropagation();
+ event.preventDefault();
+ self._detachEditModeEventHandlers();
+ self._attachEditModeEventHandlers();
self.stopEditing( dropValue );
+ }
+
+ this.$mainSnak.one( 'snakviewstopediting', function( event,
dropValue ) {
+ defaultHandling( event, dropValue );
} );
if ( this._qualifiers ) {
this._qualifiers.element.one(
'snaklistviewstopediting', function( event, dropValue ) {
- self.stopEditing( dropValue );
+ defaultHandling( event, dropValue );
} );
}
},
@@ -526,7 +534,11 @@
}
},
snaklistviewdisable: function( event ) {
- $( event.target ).data( 'addtoolbar'
).toolbar.disable();
+ var addToolbar = $( event.target ).data( 'addtoolbar' );
+ // Toolbar might be removed from the DOM already after
having stopped edit mode.
+ if ( addToolbar ) {
+ addToolbar.toolbar.disable();
+ }
},
snaklistviewenable: function( event ) {
var addToolbar = $( event.target ).data( 'addtoolbar' );
@@ -543,6 +555,11 @@
snaklistview = $snaklistviewNode.data(
'snaklistview' ),
addToolbar = $snaklistviewNode.data(
'addtoolbar' );
+ // Toolbar is not within the DOM when (re-)constructing
the list in non-edit-mode.
+ if ( !addToolbar ) {
+ return;
+ }
+
// Disable add toolbar when the last qualifier has
been removed:
if ( !snaklistview.isValid() listview.items().length
) {
addToolbar.toolbar.disable();
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js
b/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js
index c73e990..c7f22ac 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.snaklistview.js
@@ -267,7 +267,10 @@
this.$listview.one( this._lia.prefixedEvent( 'stopediting.' +
this.widgetName ),
function( event, dropValue, newSnak ) {
+ event.stopImmediatePropagation();
event.preventDefault();
+ self._detachEditModeEventHandlers();
+ self._attachEditModeEventHandlers();
self.stopEditing( dropValue );
}
);
--
To view, visit https://gerrit.wikimedia.org/r/60643
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iae0160abc38a1c842ff2ead3fbd8f24aa8a6bfe6
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater henning.sna...@wikimedia.de
Gerrit-Reviewer: Daniel Werner daniel.wer...@wikimedia.de
Gerrit-Reviewer: Tobias Gritschacher tobias.gritschac...@wikimedia.de
Gerrit-Reviewer: jenkins-bot
___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits