Skip to content

Commit

Permalink
Fix toolbox update when clicking on virus-tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
tverbeiren committed Sep 27, 2023
1 parent 2463c5a commit bba2853
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions _js/family.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ clearToolbox = () => {
// Update the tools in the toolbox based on the provided virus object
updateToolbox = (virus) => {
console.log(virus)
d3.select("#virus").text(virus.resVirusName)
toolbox
.filter(tool => virus.tools.includes(tool.id))
Expand Down Expand Up @@ -274,12 +276,16 @@ virusHoverOut = () => {
// Clicking on the tabs feeds the info back to the toolbox info
feedbackToolbox = d3.selectAll(".nav-item")
.on('click', function(){
.on('click', function(){
const _id = d3.select(this).select("a").attr('id')
const _virus_id = tabToVirusIdMap.get(_id)
const _virus = virusIdToVirus(_virus_id)
clearToolbox();
updateToolbox(_virus)
// We should only update the toolbox if an actual virus is selected
// not if for instance the 'toolbox' tab is selected
if (typeof _virus_id !== "undefined") {
const _virus = virusIdToVirus(_virus_id)
clearToolbox();
updateToolbox(_virus)
}
})
// Add SVG to the DOM
Expand Down

0 comments on commit bba2853

Please sign in to comment.