GenSpectrum / dashboard-components

https://genspectrum.github.io/dashboard-components/
GNU Affero General Public License v3.0
2 stars 0 forks source link

Mutation over time grid doesn't show numbers when switching tabs #517

Closed chaoran-chen closed 1 week ago

chaoran-chen commented 1 week ago

In my PR for the wastewater mutations over time plot (#504), I'm reusing the existing mutations over time grid and am observing a bug where the proportion numbers don't display initially when switching the tab but become visible if we change the size of the window:

https://dashboard-components-git-wastewater-mutations-cov-spectrum.vercel.app/?path=/story/visualization-wastewater-mutations-over-time--default

https://github.com/user-attachments/assets/2be8b9d0-6119-4673-b9b4-f27a0d6d7149

fengelniederhammer commented 1 week ago

The problem is the following:

We use this function to compute whether to show the proportion number or not: https://github.com/GenSpectrum/dashboard-components/blob/81327971bb353c55bedc016919dc1878d3575844/components/src/preact/mutationsOverTime/mutations-over-time-grid.tsx#L90-L113

When the tab is not visible, then checkWidth will execute gridRef.current.getBoundingClientRect().width, which evaluates to 0 (since that grid is currently not visible). Thus, the proportions are not shown. The component does not receive an update when switching tabs.