Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/275698
Change subject: CapsuleMultiSelectWidget: Emit 'resize' when widget height
changes
......................................................................
CapsuleMultiSelectWidget: Emit 'resize' when widget height changes
Bug: T129158
Change-Id: I22efd3bc5c66a547a89445b4c826877e18e36f8a
---
M src/widgets/CapsuleMultiSelectWidget.js
1 file changed, 23 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/98/275698/1
diff --git a/src/widgets/CapsuleMultiSelectWidget.js
b/src/widgets/CapsuleMultiSelectWidget.js
index 53dab89..d12b9b6 100644
--- a/src/widgets/CapsuleMultiSelectWidget.js
+++ b/src/widgets/CapsuleMultiSelectWidget.js
@@ -190,6 +190,13 @@
* @param {Mixed[]} datas Data of the now-selected items
*/
+/**
+ * @event resize
+ *
+ * A resize event is emitted when the widget's dimensions change to accomodate
newly added items or
+ * current user input.
+ */
+
/* Methods */
/**
@@ -352,7 +359,7 @@
}
if ( !same ) {
this.emit( 'change', this.getItemsData() );
- this.menu.position();
+ this.updateIfHeightChanged();
}
return this;
@@ -389,7 +396,7 @@
}
if ( !same ) {
this.emit( 'change', this.getItemsData() );
- this.menu.position();
+ this.updateIfHeightChanged();
}
return this;
@@ -402,7 +409,7 @@
if ( this.items.length ) {
OO.ui.mixin.GroupElement.prototype.clearItems.call( this );
this.emit( 'change', this.getItemsData() );
- this.menu.position();
+ this.updateIfHeightChanged();
}
return this;
};
@@ -632,8 +639,21 @@
bestWidth = this.$content.innerWidth() - 10;
}
this.$input.width( Math.floor( bestWidth ) );
+ this.updateIfHeightChanged();
+ }
+};
+/**
+ * Determine if widget height changed, and if so, update menu position and
emit 'resize' event.
+ *
+ * @private
+ */
+OO.ui.CapsuleMultiSelectWidget.prototype.updateIfHeightChanged = function () {
+ var height = this.$element.height();
+ if ( height !== this.height ) {
+ this.height = height;
this.menu.position();
+ this.emit( 'resize' );
}
};
--
To view, visit https://gerrit.wikimedia.org/r/275698
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I22efd3bc5c66a547a89445b4c826877e18e36f8a
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits