googlearchive / paper-dialog

A dialog à la Material Design
19 stars 16 forks source link

external event for 'opened' changed #13

Closed yoavniran closed 9 years ago

yoavniran commented 9 years ago

Im very new to Polymer but unless Im missing some fundamental concept, I dont see how I can listen on the opened property changing when im using the paper-dialog element.

I want one part of my code (controller) to set the opened state and another part of the code (view) to listen on the state changing.

I dont see how I can do it right now although it seems to me like a very trivial requirement.

Am I missing something or is this just not possible with they way its built now?

thanks

morethanreal commented 9 years ago

You can listen to the core-overlay-open event on the paper-dialog to get notified when the dialog is opened or closed. event.detail.opened will give you the opened state. I've updated the doc to include this info.

yoavniran commented 9 years ago

thanks. that did the trick.

I did however notice something that you might call a bug. when core-overlay fires the event for closing in the "openedChanged" handler, when the dialog is closing its doing:

this.fire('core-overlay-open', this.opened);  

with this.opened being false.

the fire function in utils.js is considering the detail as empty and replaces it with an empty object.

var detail = detail || {};

So the event that gets fired has its "detail" property set to: {} instead of false. when this.opened is true I get the correct value. seems like unexpected behavior to me.

thanks, Yoav

sjmiles commented 9 years ago

Fwiw, the detail flaw is fixed here https://github.com/Polymer/polymer-dev/commit/43fe8b94c43e78f530fbdf1d0301448eeece7401.

yoavniran commented 9 years ago

cool, thanks