Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Paper Dialog AutoFocus and Size Fix
window.addEventListener('iron-overlay-opened', fixDialog);
function fixDialog (dore) {
var dialog = (typeof dore.tagName != 'undefined') ? dore : dore.target;
if(dialog.tagName == 'PAPER-DIALOG') {
dialog.fit();
var input = dialog.querySelector('[autofocus]');
if(input) {
if(typeof input.dataset.highlight != 'undefined') var highlight = true;
switch(input.tagName.toLowerCase()) {
case 'paper-textarea':
case 'paper-input':
input.$.input.focus();
if(highlight) input.$.input.select();
break;
case 'input':
input.focus();
if(highlight) input.select();
break;
case 'iron-autogrow-textarea':
console.log("Here!");
break;
default:
console.log("Tried to focus:",input.tagName.toLowerCase());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.