polymer - autofocus paper-input in a paper-dialog works only once? -


<paper-dialog>   <h2>rename</h2>   <div>     <paper-input autofocus></paper-input>   </div>   <div class="buttons">     <paper-button dialog-dismiss>cancel</paper-button>     <paper-button dialog-confirm on-click="_confirm">rename</paper-button>   </div> </paper-dialog> 

this paper-dialog triggers autofocus on it's paper-input first time open it.

how can trigger focus every time open dialog?

to fix autofocusing on dialogs, had use event listener , manually focus element.

for example:

window.addeventlistener('iron-overlay-opened', function(event) {     // grab autofocus input     var input = event.target.queryselector('[autofocus]');     // switch because require special treatment     switch(input.tagname.tolowercase()) {         case 'input':             input.focus();             break;         case 'paper-textarea':         case 'paper-input':             input.$.input.focus();             break;     } }); 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -