Bartosz Dziewoński has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/187954

Change subject: TextInputWidget: Mostly revert "Don't try adjusting size when 
detached"
......................................................................

TextInputWidget: Mostly revert "Don't try adjusting size when detached"

We can't depend on the DOMNodeRemovedFromDocument event for basic
functionality like this. This actually breaks in Firefox at least,
and probably some other browsers too.

Use a simpler solution for T85689: just clear valCache when we detect
attachment. This is of course still partial and does not help browsers
not supporting DOMNodeInsertedIntoDocument, but at least we don't
entirely disable size adjustment on them like we accidentally did
before.

This reverts most of commit 4b42fbe4f5ad806d0bb82c0793f028280ac1a16d.

Bug: T88212
Change-Id: Ibb027bfaa29f95fc67afd70c9606ef23e8691550
---
M src/widgets/TextInputWidget.js
1 file changed, 2 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/54/187954/1

diff --git a/src/widgets/TextInputWidget.js b/src/widgets/TextInputWidget.js
index afcff10..7156bb7 100644
--- a/src/widgets/TextInputWidget.js
+++ b/src/widgets/TextInputWidget.js
@@ -45,7 +45,6 @@
        this.autosize = !!config.autosize;
        this.maxRows = config.maxRows;
        this.validate = null;
-       this.attached = false;
 
        // Clone for resizing
        if ( this.autosize ) {
@@ -64,7 +63,6 @@
                blur: this.setValidityFlag.bind( this )
        } );
        this.$element.on( 'DOMNodeInsertedIntoDocument', 
this.onElementAttach.bind( this ) );
-       this.$element.on( 'DOMNodeRemovedFromDocument', 
this.onElementDetach.bind( this ) );
        this.$icon.on( 'mousedown', this.onIconMouseDown.bind( this ) );
        this.$indicator.on( 'mousedown', this.onIndicatorMouseDown.bind( this ) 
);
        this.on( 'labelChange', this.updatePosition.bind( this ) );
@@ -170,20 +168,10 @@
  * @param {jQuery.Event} e Element attach event
  */
 OO.ui.TextInputWidget.prototype.onElementAttach = function () {
-       this.attached = true;
-       // If we reattached elsewhere, the valCache is now invalid
+       // Any previously calculated size is now probably invalid if we 
reattached elsewhere
        this.valCache = null;
        this.adjustSize();
        this.positionLabel();
-};
-
-/**
- * Handle element detach events.
- *
- * @param {jQuery.Event} e Element detach event
- */
-OO.ui.TextInputWidget.prototype.onElementDetach = function () {
-       this.attached = false;
 };
 
 /**
@@ -241,7 +229,7 @@
 OO.ui.TextInputWidget.prototype.adjustSize = function () {
        var scrollHeight, innerHeight, outerHeight, maxInnerHeight, 
measurementError, idealHeight;
 
-       if ( this.multiline && this.autosize && this.attached && 
this.$input.val() !== this.valCache ) {
+       if ( this.multiline && this.autosize && this.$input.val() !== 
this.valCache ) {
                this.$clone
                        .val( this.$input.val() )
                        .attr( 'rows', '' )

-- 
To view, visit https://gerrit.wikimedia.org/r/187954
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibb027bfaa29f95fc67afd70c9606ef23e8691550
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

Reply via email to