From 375c2fd07578829bcb1a71fcbc7b8b9da90ff68a Mon Sep 17 00:00:00 2001 From: xangelo Date: Tue, 6 Jun 2023 15:22:57 -0400 Subject: [PATCH] fix: switching between tabs doesnt always work --- public/assets/css/game.css | 3 +++ src/client/index.ts | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/public/assets/css/game.css b/public/assets/css/game.css index eb79b1b..6d8387f 100644 --- a/public/assets/css/game.css +++ b/public/assets/css/game.css @@ -178,6 +178,9 @@ nav a.active { .tab { display: none; } +.tab.active { + display: block; +} #main-nav { margin-bottom: 2rem; } diff --git a/src/client/index.ts b/src/client/index.ts index 63613e8..d5caf51 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -184,10 +184,11 @@ $('nav a').on('click', e => { e.preventDefault(); e.stopPropagation(); - const tabContainer = $(e.target).data('container'); + const $tabContainer = $(`#${$(e.target).data('container')}`); - $(`#${tabContainer} .tab`).css('display', 'none'); - $(`#${$(e.target).data('section')}`).css('display', 'block'); + $tabContainer.find('.tab').removeClass('active'); + + $(`#${$(e.target).data('section')}`).addClass('active'); $(e.target).closest('nav').find('a').removeClass('active'); $(e.target).addClass('active'); -- 2.25.1