jenkins-bot has submitted this change and it was merged.
Change subject: TextInputWidget: Emit 'resize' events
......................................................................
TextInputWidget: Emit 'resize' events
Bug: T116186
Change-Id: Iaadaf1f9ffe9474d2e7bf2dedd1a0ac910dbaa55
---
M src/widgets/TextInputWidget.js
1 file changed, 15 insertions(+), 6 deletions(-)
Approvals:
Bartosz Dziewoński: Looks good to me, approved
jenkins-bot: Verified
diff --git a/src/widgets/TextInputWidget.js b/src/widgets/TextInputWidget.js
index 9dddc9e..e09c78c 100644
--- a/src/widgets/TextInputWidget.js
+++ b/src/widgets/TextInputWidget.js
@@ -90,6 +90,7 @@
this.minRows = config.rows !== undefined ? config.rows : '';
this.maxRows = config.maxRows || Math.max( 2 * ( this.minRows || 0 ),
10 );
this.validate = null;
+ this.styleHeight = null;
// Clone for resizing
if ( this.autosize ) {
@@ -184,6 +185,12 @@
* Not emitted if the input is multiline.
*
* @event enter
+ */
+
+/**
+ * A `resize` event is emitted when autosize is set and the widget resizes
+ *
+ * @event resize
*/
/* Methods */
@@ -375,9 +382,10 @@
* This only affects #multiline inputs that are {@link #autosize autosized}.
*
* @chainable
+ * @fires resize
*/
OO.ui.TextInputWidget.prototype.adjustSize = function () {
- var scrollHeight, innerHeight, outerHeight, maxInnerHeight,
measurementError, idealHeight;
+ var scrollHeight, innerHeight, outerHeight, maxInnerHeight,
measurementError, idealHeight, newHeight;
if ( this.multiline && this.autosize && this.$input.val() !==
this.valCache ) {
this.$clone
@@ -412,11 +420,12 @@
this.$clone.addClass( 'oo-ui-element-hidden' );
// Only apply inline height when expansion beyond natural
height is needed
- if ( idealHeight > innerHeight ) {
- // Use the difference between the inner and outer
height as a buffer
- this.$input.css( 'height', idealHeight + ( outerHeight
- innerHeight ) );
- } else {
- this.$input.css( 'height', '' );
+ // Use the difference between the inner and outer height as a
buffer
+ newHeight = idealHeight > innerHeight ? idealHeight + (
outerHeight - innerHeight ) : '';
+ if ( newHeight !== this.styleHeight ) {
+ this.$input.css( 'height', newHeight );
+ this.styleHeight = newHeight;
+ this.emit( 'resize' );
}
}
return this;
--
To view, visit https://gerrit.wikimedia.org/r/247860
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaadaf1f9ffe9474d2e7bf2dedd1a0ac910dbaa55
Gerrit-PatchSet: 2
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits