From a03961f379092275e635d9a80e87e713eea83d55 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Thu, 22 Mar 2018 19:56:08 -0700 Subject: [PATCH] attempt to fix focus crash issue --- routes/_components/timeline/Timeline.html | 48 +++++++++++++---------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/routes/_components/timeline/Timeline.html b/routes/_components/timeline/Timeline.html index 412483d..cae6ea0 100644 --- a/routes/_components/timeline/Timeline.html +++ b/routes/_components/timeline/Timeline.html @@ -256,31 +256,39 @@ this.store.setForCurrentTimeline({ ignoreBlurEvents: true }) }, saveFocus(e) { - let instanceName = this.store.get('currentInstance') - let timelineName = this.get('timeline') - let lastFocusedElementSelector - let activeElement = e.target - if (activeElement) { - let focusKey = activeElement.getAttribute('focus-key') - if (focusKey) { - lastFocusedElementSelector = `[focus-key=${JSON.stringify(focusKey)}]` + try { + let instanceName = this.store.get('currentInstance') + let timelineName = this.get('timeline') + let lastFocusedElementSelector + let activeElement = e.target + if (activeElement) { + let focusKey = activeElement.getAttribute('focus-key') + 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() { - if (this.store.get('ignoreBlurEvents')) { - return + try { + 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 - }) } } }