Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-5455

Popup causes error if parent is removed during popup opening animation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 10.1.0
    • 10.0.0, 9.6.3, 9.6.4
    • None
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      Currently no easy reproducing case, since it is a race condition.

      Current Result

      When anchor component is removed in between popup.open and popup.reposition (called after finishing to animate popup opening):

      caught (in promise) TypeError: Cannot read properties of undefined (reading 'style')
          at zjq.dimension (zk.wpd:14096:27)
          at init.getPositionArgs_ (zk.wpd:45729:21)
          at init.reposition (zk.wpd:45695:38)
          at init.afterSize (zk.wpd:45686:10)
          at _invoke (zk.wpd:15762:14)
          at init.fire (zk.wpd:15748:9)
          at _fire (zk.wpd:15905:13)
          at Object.fireDown (zk.wpd:16138:7)
          at Object.fireDown (zk.wpd:18073:28)
          at Object.fireSized (zk.wpd:18961:16)
      

      Expected Result

      harden popup reposition to check if _fakeParent is attached to the page
      (currenly only check for _fakeParent being present)

      Debug Information

      https://github.com/zkoss/zk/blob/6db078f210b8fcdfcda42d2c0f599c8d69410efc/zul/src/archive/web/js/zul/wgt/Popup.js#L403

      Workaround

        <script><![CDATA[
            zk.afterLoad("zul.wgt", function () {
                var _xPopup = {};
                zk.override(zul.wgt.Popup.prototype, _xPopup, {
                    reposition: function() {
                        if(!this._fakeParent || !(this._fakeParent && this._fakeParent.$n() == null)){
      						return _xPopup.reposition.apply(this, arguments);
                        }else{
      						try{
      							console.log("closing popup due to anchor not existing in page.");
                              	this.close();
                          	}catch(e){
                              	console.warn(e.stack);
                            	}                        
                        }
                    }
                 });
            });
        ]]></script>
      

            jumperchen jumperchen
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: