diff --git a/src/app/panels/file-panel.js b/src/app/panels/file-panel.js
index e3e8e4c919..371c435380 100644
--- a/src/app/panels/file-panel.js
+++ b/src/app/panels/file-panel.js
@@ -242,7 +242,7 @@ function filepanel (appAPI, filesProvider) {
appAPI.switchFile(filesProvider['browser'].type + '/' + newName)
}
})
- })
+ }, null, true)
}
/**
diff --git a/src/app/ui/modal-dialog-custom.js b/src/app/ui/modal-dialog-custom.js
index 470b4343e7..f793a892f6 100644
--- a/src/app/ui/modal-dialog-custom.js
+++ b/src/app/ui/modal-dialog-custom.js
@@ -6,8 +6,8 @@ module.exports = {
alert: function (text) {
modal('', yo`
${text}
`, null, { label: null })
},
- prompt: function (title, text, inputValue, ok, cancel) {
- prompt(title, text, false, inputValue, ok, cancel)
+ prompt: function (title, text, inputValue, ok, cancel, focus) {
+ prompt(title, text, false, inputValue, ok, cancel, focus)
},
promptPassphrase: function (title, text, inputValue, ok, cancel) {
prompt(title, text, true, inputValue, ok, cancel)
@@ -63,7 +63,7 @@ module.exports = {
}
}
-function prompt (title, text, hidden, inputValue, ok, cancel) {
+function prompt (title, text, hidden, inputValue, ok, cancel, focus) {
if (!inputValue) inputValue = ''
var type = hidden ? 'password' : 'text'
var input = yo``
@@ -73,6 +73,7 @@ function prompt (title, text, hidden, inputValue, ok, cancel) {
},
{
fn: () => { if (typeof cancel === 'function') cancel() }
- }
+ },
+ focus ? '#prompt_text' : undefined
)
}
diff --git a/src/app/ui/modaldialog.js b/src/app/ui/modaldialog.js
index 6cee053951..664dd9b0bc 100644
--- a/src/app/ui/modaldialog.js
+++ b/src/app/ui/modaldialog.js
@@ -1,7 +1,7 @@
var yo = require('yo-yo')
var css = require('./styles/modaldialog-styles')
-module.exports = (title, content, ok, cancel) => {
+module.exports = (title, content, ok, cancel, focusSelector) => {
var container = document.querySelector(`.${css.modal}`)
if (!container) {
document.querySelector('body').appendChild(html())
@@ -54,6 +54,15 @@ module.exports = (title, content, ok, cancel) => {
function show () {
container.style.display = 'block'
+ if (focusSelector) {
+ const focusTarget = document.querySelector(`.${css.modal} ${focusSelector}`)
+ if (focusTarget) {
+ focusTarget.focus()
+ if (typeof focusTarget.setSelectionRange === 'function') {
+ focusTarget.setSelectionRange(0, focusTarget.value.length)
+ }
+ }
+ }
}
function removeEventListener () {