Search code examples
dartdart-polymerpaper-elements

Prevent paper-dialog from automatically closing


Hello:

I have a paper-dialog element in a page:

<paper-dialog ... id="autom_desc_dialog" autoCloseDisabled> 
    ...
    <paper-button ... id="automatizar" affirmative autofocus disabled></paper-button>
</paper-dialog>

and I have an event listener that handles the paper-button click:

var auto_btn = querySelector('#automatizar');
auto_btn.on["click"].listen((Event e) {
    // Some AJAX stuff
});

What I want is that in some cases, to be able to prevent the dialog from closing, I've tried event.preventDefault(), event.stopImmediatePropagation(), event.stopPropagation() but no success.

Thanks in advance.


Solution

  • You don't need to remove affirmative/dismissive attributes as they are used for layout. Polymer dialog docs are wrong (I've opened a GH issue) the default value for closeSelector is '[dismissive],[affirmative]' and not "", you just need to set closeSelector to "" and it won't close the dialog on clicking the buttons.