attempt to fix focus crash issue

This commit is contained in:
Nolan Lawson 2018-03-22 19:56:08 -07:00
parent 62ef9d7bb0
commit a03961f379

View file

@ -256,31 +256,39 @@
this.store.setForCurrentTimeline({ ignoreBlurEvents: true }) this.store.setForCurrentTimeline({ ignoreBlurEvents: true })
}, },
saveFocus(e) { saveFocus(e) {
let instanceName = this.store.get('currentInstance') try {
let timelineName = this.get('timeline') let instanceName = this.store.get('currentInstance')
let lastFocusedElementSelector let timelineName = this.get('timeline')
let activeElement = e.target let lastFocusedElementSelector
if (activeElement) { let activeElement = e.target
let focusKey = activeElement.getAttribute('focus-key') if (activeElement) {
if (focusKey) { let focusKey = activeElement.getAttribute('focus-key')
lastFocusedElementSelector = `[focus-key=${JSON.stringify(focusKey)}]` if (focusKey) {
lastFocusedElementSelector = `[focus-key=${JSON.stringify(focusKey)}]`
}
} }
console.log('saving focus to ', lastFocusedElementSelector)
this.store.setForTimeline(instanceName, timelineName, {
lastFocusedElementSelector
})
} catch (err) {
console.error('unable to save focus', err)
} }
console.log('saving focus to ', lastFocusedElementSelector)
this.store.setForTimeline(instanceName, timelineName, {
lastFocusedElementSelector
})
}, },
clearFocus() { clearFocus() {
if (this.store.get('ignoreBlurEvents')) { try {
return if (this.store.get('ignoreBlurEvents')) {
return
}
console.log('clearing focus')
let instanceName = this.store.get('currentInstance')
let timelineName = this.get('timeline')
this.store.setForTimeline(instanceName, timelineName, {
lastFocusedElementSelector: null
})
} catch (err) {
console.error('unable to clear focus', err)
} }
console.log('clearing focus')
let instanceName = this.store.get('currentInstance')
let timelineName = this.get('timeline')
this.store.setForTimeline(instanceName, timelineName, {
lastFocusedElementSelector: null
})
} }
} }
} }