From: Ed Sanders Date: Mon, 29 Jul 2019 14:51:33 +0000 (+0100) Subject: CopyTextLayout: Only select-all on focus X-Git-Tag: 1.34.0-rc.0~851^2 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=1597eeda1eb638dc95b3b191bf9b0e5b1c5ec4be;p=lhc%2Fweb%2Fwiklou.git CopyTextLayout: Only select-all on focus This allows users to partially select the text, which is useful in some cases, but still makes it easy to copy either using a keyboard shortcut or the ButtonWidget. Bug: T110579 Change-Id: I5be1530bb2cca9f8251e2e1c87a85e1e79cfe47f --- diff --git a/resources/src/mediawiki.widgets/mw.widgets.CopyTextLayout.js b/resources/src/mediawiki.widgets/mw.widgets.CopyTextLayout.js index 65e7eb782a..56419aee68 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.CopyTextLayout.js +++ b/resources/src/mediawiki.widgets/mw.widgets.CopyTextLayout.js @@ -54,7 +54,7 @@ // Events this.button.connect( this, { click: 'onButtonClick' } ); - this.textInput.$input.on( 'click', this.onInputClick.bind( this ) ); + this.textInput.$input.on( 'focus', this.onInputFocus.bind( this ) ); this.$element.addClass( 'mw-widget-copyTextLayout' ); }; @@ -90,10 +90,12 @@ }; /** - * Handle button click events + * Handle text widget focus events */ - mw.widgets.CopyTextLayout.prototype.onInputClick = function () { - this.selectText(); + mw.widgets.CopyTextLayout.prototype.onInputFocus = function () { + if ( !this.selecting ) { + this.selectText(); + } }; /** @@ -104,7 +106,9 @@ scrollTop = input.scrollTop, scrollLeft = input.scrollLeft; + this.selecting = true; this.textInput.select(); + this.selecting = false; // Restore scroll position input.scrollTop = scrollTop;