jenkins-bot has submitted this change and it was merged.
Change subject: Close language selector if group selector is opened
......................................................................
Close language selector if group selector is opened
e.stopPropagation is harmful and causes problems like this.
It was used to prevent the dialog being closed immediately.
Instead, use a check in hide to ignore clicks on the trigger.
Clicks inside the dialog still use e.stopPropagation.
Small optimization with firstShow to not re-rerender the list
each time it is opened.
Bug: T47699
Change-Id: Idbbecb9c6c97cd301e4b53948098e5e27816cb95
---
M resources/js/ext.translate.groupselector.js
1 file changed, 15 insertions(+), 12 deletions(-)
Approvals:
Santhosh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/resources/js/ext.translate.groupselector.js
b/resources/js/ext.translate.groupselector.js
index a10ee58..f755b48 100644
--- a/resources/js/ext.translate.groupselector.js
+++ b/resources/js/ext.translate.groupselector.js
@@ -24,6 +24,7 @@
this.customOptions = options;
this.flatGroupList = null;
this.groups = groups;
+ this.firstShow = true;
this.init();
}
@@ -117,25 +118,27 @@
* Show the selector
*/
show: function () {
- // Hide all other open menus
- $( '.tux-groupselector.open' )
- .removeClass( 'open' )
- .hide();
this.$menu.addClass( 'open' ).show();
this.position();
// Place the focus in the message group search box.
this.$search.focus();
// Start loading the groups, but assess the situation
again after
// they are loaded, in case user has made further
interactions.
- this.loadGroups().done( $.proxy( this.showList, this )
);
- // Hide the selector panel when clicking outside of it
- $( 'html' ).one( 'click', $.proxy( this.hide, this ) );
+ if ( this.firstShow ) {
+ this.loadGroups().done( $.proxy( this.showList,
this ) );
+ this.firstShow = false;
+ }
},
/**
* Hide the selector
*/
- hide: function () {
+ hide: function ( e ) {
+ // Do not hide if the trigger is clicked
+ if ( e && this.$trigger.is( e.target ) ) {
+ return;
+ }
+
this.$menu.hide().removeClass( 'open' );
},
@@ -157,11 +160,11 @@
var $tabs,
groupSelector = this;
- groupSelector.$trigger.on( 'click', function ( e ) {
- groupSelector.toggle();
+ // Hide the selector panel when clicking outside of it
+ $( 'html' ).on( 'click', $.proxy( this.hide, this ) );
- e.preventDefault();
- e.stopPropagation();
+ groupSelector.$trigger.on( 'click', function () {
+ groupSelector.toggle();
} );
groupSelector.$menu.on( 'click', function ( e ) {
--
To view, visit https://gerrit.wikimedia.org/r/205552
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Idbbecb9c6c97cd301e4b53948098e5e27816cb95
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Phoenix303 <[email protected]>
Gerrit-Reviewer: Amire80 <[email protected]>
Gerrit-Reviewer: Nemo bis <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Phoenix303 <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits