From e0170731425842d965b9dfa1bccea5c61ec2b99e Mon Sep 17 00:00:00 2001 From: Quincy Morgan <2046746+quincylvania@users.noreply.github.com> Date: Fri, 30 Oct 2020 09:48:48 -0400 Subject: [PATCH] Fix issue where the keyboard shortcuts screen would only display the first tab (close #8137) --- modules/ui/shortcuts.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/modules/ui/shortcuts.js b/modules/ui/shortcuts.js index df9d3dd53..df50176f5 100644 --- a/modules/ui/shortcuts.js +++ b/modules/ui/shortcuts.js @@ -14,6 +14,7 @@ export function uiShortcuts(context) { var _activeTab = 0; var _modalSelection; var _selection = d3_select(null); + var _dataShortcuts; function shortcutsModal(_modalSelection) { @@ -29,12 +30,17 @@ export function uiShortcuts(context) { .html(t.html('shortcuts.title')); fileFetcher.get('shortcuts') - .then(function(data) { content.call(render, data); }) + .then(function(data) { + _dataShortcuts = data; + content.call(render); + }) .catch(function() { /* ignore */ }); } - function render(selection, dataShortcuts) { + function render(selection) { + if (!_dataShortcuts) return; + var wrapper = selection .selectAll('.wrapper') .data([0]); @@ -56,18 +62,18 @@ export function uiShortcuts(context) { var tabs = tabsBar .selectAll('.tab') - .data(dataShortcuts); + .data(_dataShortcuts); var tabsEnter = tabs .enter() .append('a') .attr('class', 'tab') .attr('href', '#') - .on('click', function (d3_event) { + .on('click', function (d3_event, d) { d3_event.preventDefault(); - var i = tabs.nodes().indexOf(this); + var i = _dataShortcuts.indexOf(d); _activeTab = i; - render(selection, dataShortcuts); + render(selection); }); tabsEnter @@ -83,7 +89,7 @@ export function uiShortcuts(context) { var shortcuts = shortcutsList .selectAll('.shortcut-tab') - .data(dataShortcuts); + .data(_dataShortcuts); var shortcutsEnter = shortcuts .enter()