neulab / explainaboard_web

MIT License
8 stars 2 forks source link

fix length mismatch bug in FineGrainedAnalysis #556

Closed lyuyangh closed 1 year ago

lyuyangh commented 1 year ago

closes #549

This bug has existed for a long time but it is made more visible in #504.

The bug

<FineGrainedBarChart /> takes systems and results as props. Whenever the user clicks on "Analysis", systems get updated immediately. results requires another API call so there is a delay in updating its value. The two props aren't always compatible because of that delay.

The fix

In <AnalysisDrawer /> (parent component of <FineGrainedBarChart />), we wait until results is updated (indicated by pageState === PageState.success) before we render <FineGrainedBarChart />. I also added validation in <FineGrainedBarChart /> which logs an error if the two props are not the same length.

I also added destroyOnClose to <AnlysisDrawer /> which destroys all the states held by <AnalysisDrawer /> when it is closed. This means all the states get reset to their initial values for every analysis. This is less efficient but it makes it easier to manage states. For example, if <AnalysisDrawer /> gets into an error state, there is no way of recovering from that at the moment. After the change, the user can recover from such an error state by closing the drawer and reanalyze.