jenkins-bot has submitted this change and it was merged. Change subject: Handle enabling/disabling buttons on right-click cut/paste. ......................................................................
Handle enabling/disabling buttons on right-click cut/paste. Bug: T73865 Change-Id: If34bc6be6164215bd9da940a3b06ec0a313827aa --- M modules/engine/misc/mw-ui.enhance.js M tests/qunit/engine/misc/test_mw-ui.enhance.js 2 files changed, 19 insertions(+), 3 deletions(-) Approvals: Matthias Mullie: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/engine/misc/mw-ui.enhance.js b/modules/engine/misc/mw-ui.enhance.js index 87bf116..60d8787 100644 --- a/modules/engine/misc/mw-ui.enhance.js +++ b/modules/engine/misc/mw-ui.enhance.js @@ -117,8 +117,17 @@ */ $( document ).ready( function () { // We should probably not use this change detection method for VE - $( document ).on( 'keyup.flow-actions-disabler', '.mw-ui-input', function () { - enableFormWithRequiredFields( $( this ).closest( 'form' ) ); + // + // Also, consider using the input event (which I think can replace all of these + // and paste) when we drop IE 8. + // https://developer.mozilla.org/en-US/docs/Web/Events/input + // setTimeout works around paste firing before the field is modified. + $( document ).on( 'keyup.flow-actions-disabler cut.flow-actions-disabler paste.flow-actions-disabler', '.mw-ui-input', function () { + var $el = $( this ); + + setTimeout( function () { + enableFormWithRequiredFields( $el.closest( 'form' ) ); + } ); } ); } ); diff --git a/tests/qunit/engine/misc/test_mw-ui.enhance.js b/tests/qunit/engine/misc/test_mw-ui.enhance.js index d5cdc55..f845bb2 100644 --- a/tests/qunit/engine/misc/test_mw-ui.enhance.js +++ b/tests/qunit/engine/misc/test_mw-ui.enhance.js @@ -1,5 +1,9 @@ ( function ( $ ) { - QUnit.module( 'ext.flow: mediawiki.ui.enhance' ); + QUnit.module( 'ext.flow: mediawiki.ui.enhance', QUnit.newMwEnvironment( { + setup: function () { + this.clock = this.sandbox.useFakeTimers(); + } + } ) ); QUnit.test( 'Forms with required fields have certain buttons disabled by default', 6, function ( assert ) { var $forms = [ @@ -16,6 +20,9 @@ this.find( '.mw-ui-input' ).trigger( 'keyup' ); } ); + // See mw-ui.enhance.js for why setTimeout is used. + this.clock.tick( 1000 ); + assert.strictEqual( $forms[0].find( 'button' ).is( ':disabled' ), true, 'Buttons with data-role=action are disabled when required fields are empty.' ); assert.strictEqual( $forms[1].find( 'button' ).is( ':disabled' ), true, -- To view, visit https://gerrit.wikimedia.org/r/198171 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If34bc6be6164215bd9da940a3b06ec0a313827aa Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Mattflaschen <mflasc...@wikimedia.org> Gerrit-Reviewer: Catrope <roan.katt...@gmail.com> Gerrit-Reviewer: Mattflaschen <mflasc...@wikimedia.org> Gerrit-Reviewer: Matthias Mullie <mmul...@wikimedia.org> Gerrit-Reviewer: SG <shah...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits