Language button should prevent default click behavior
In Vector the language button is a checkbox. It uses the checkbox hack to provide non-JS dropdown behaviour. When the JS upgrades such a button, the checkbox behavior continues to work. An unsatisfying hack in Vector workarounds this problem. This provides a neater way to disable that behavior in Vector once the button is clicked by adding support for the well documented checkbox hack. Bug: T283757 Change-Id: I97a69c30b27cb1ded06451389e086229561c3589
This commit is contained in:
@@ -439,8 +439,23 @@
|
||||
* @param {jQuery.Event} ev
|
||||
*/
|
||||
function loadContentLanguageSelector( ev ) {
|
||||
var $target = $( ev.currentTarget );
|
||||
var targetNode = ev.currentTarget,
|
||||
$target = $( targetNode );
|
||||
ev.preventDefault();
|
||||
// Special handling for checkboxes
|
||||
if (
|
||||
targetNode &&
|
||||
targetNode.tagName === 'INPUT' &&
|
||||
targetNode.getAttribute( 'type' ) === 'checkbox'
|
||||
) {
|
||||
// Disabled checked status. If the ULS button is also a checkbox, we can
|
||||
// conclude that it's using the checkbox hack.
|
||||
// Setting checked to false disables the default behavior of that checkbox.
|
||||
targetNode.checked = false;
|
||||
$target.on( 'click', function () {
|
||||
targetNode.checked = false;
|
||||
} );
|
||||
}
|
||||
|
||||
// Avoid reinitializing ULS multiple times for an element
|
||||
if ( $target.attr( 'data-uls-loaded' ) ) {
|
||||
|
||||
Reference in New Issue
Block a user