paper-dialog in Polymer doesn't close in iPhone

假装没事ソ 提交于 2019-12-06 21:57:55

问题


I use this example from the doc of polymer

 <paper-dialog>
    <h2>Header</h2>
    <paper-dialog-scrollable>
        Lorem ipsum...
    </paper-dialog-scrollable>
    <div class="buttons">
     <paper-button dialog-dismiss>Cancel</paper-button>
     <paper-button dialog-confirm>Accept</paper-button>
   </div>
</paper-dialog>

In every browser the dialog closes when I click on place that is not the dialog, But on iPhone IOS 8.4 it doesn't work. I can't close the dialog.

How can I solve this problem?


回答1:


I know there is a Z-index issue with Safari on IOS. Likely the paper-dialog is not at the top like it should be. You may need a -webkit prefix to the class when it's using IOS.




回答2:


After some research, I found the issue on the polymer Github, and there is a way to hack it so it works:

    _finishRenderOpened: function() {
  // focus the child node with [autofocus]
  if (!this.noAutoFocus) {
    this._focusNode.focus();
  }

  if(this.withBackdrop) {
    this.parentNode.insertBefore(this._backdrop, this);
  }

  this.fire('iron-overlay-opened');

  this._squelchNextResize = true;
  this.async(this.notifyResize);
},

(code by https://github.com/dhpollack)

"To implement dhpollack's hack in a nice way, add this function to your custom element:

patchOverlay: function (e) {
    if (e.target.withBackdrop) {
        e.target.parentNode.insertBefore(e.target._backdrop, e.target);
    }
},

And add on-iron-overlay-opened="patchOverlay" to all your <paper-dialog>'s"

(implementation by https://github.com/rubenstolk)

Github issue: https://github.com/PolymerElements/paper-dialog/issues/7

Hope it works for you :)



来源:https://stackoverflow.com/questions/33075990/paper-dialog-in-polymer-doesnt-close-in-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!