I'm trying to use the 'paper-dialog' tag for Polymer 2 in a web component.
I'm trying to detect when the user clicks the cancel button vs the save/ok button.
The documenation says to create an event for 'iron-overlay-closed' to detect when the OK/Save button is clicked.
My problem is that the 'iron-overlay-closed' is firing even when I click the cancel button.
From my reading of the documentation only the button with dialog-confirm attribute should cause the event to fire.
<paper-dialog modal backdrdop id="dialog">
<h2>Select Time</h2>
<paper-dialog-scrollable>
<div slot="body">
<p>Body is here</p>
</div>
</paper-dialog-scrollable>
<div id="dialog-buttons">
<paper-button dialog-dismiss>Cancel</paper-button>
<paper-button dialog-confirm autofocus>Save</paper-button>
</div>
</paper-dialog>
The below open method adds the listener.
The fireCallback method is then closed regardless of whether I click Save or Cancel.
open()
{
this.$.dialog.addEventListener('iron-overlay-closed', ()=> {this.fireCallback()});
this.$.dialog.open();
}
fireCallback()
{
console.log("closing");
}