Skip to content

Commit

Permalink
Keep cursor focused after action button click.
Browse files Browse the repository at this point in the history
This closes jaredreich#30, closes jaredreich#26.
  • Loading branch information
jaredreich committed Mar 10, 2018
1 parent c012e11 commit e47671e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/pell.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,6 @@ export const init = settings => {

const actionbar = document.createElement('div')
actionbar.className = settings.classes.actionbar
settings.actions.forEach(action => {
const button = document.createElement('button')
button.className = settings.classes.button
button.innerHTML = action.icon
button.title = action.title
button.setAttribute('type', 'button')
button.onclick = action.result
actionbar.appendChild(button)
})
settings.element.appendChild(actionbar)

settings.element.content = document.createElement('div')
Expand All @@ -122,6 +113,16 @@ export const init = settings => {
settings.element.content.onkeydown = preventTab
settings.element.appendChild(settings.element.content)

settings.actions.forEach(action => {
const button = document.createElement('button')
button.className = settings.classes.button
button.innerHTML = action.icon
button.title = action.title
button.setAttribute('type', 'button')
button.onclick = () => action.result() || settings.element.content.focus()
actionbar.appendChild(button)
})

if (settings.styleWithCSS) exec('styleWithCSS')

return settings.element
Expand Down

0 comments on commit e47671e

Please sign in to comment.