Skip to content

Commit 3b21900

Browse files
committed
frontend: fix chart edgecase to properly update the total amount
On mobile the total changes when the user selects a point on the chart so that they can see exact amount at the time. With scrolling or 2nd finger changing the currency it can happen that the amount does not update, ending up with a wrong amount/unit. Fixed by resetting the tooltip value if the currency changes.
1 parent 0c3f44f commit 3b21900

File tree

1 file changed

+11
-0
lines changed
  • frontends/web/src/routes/account/summary

1 file changed

+11
-0
lines changed

frontends/web/src/routes/account/summary/chart.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { PercentageDiff } from './percentage-diff';
2626
import { Filters } from './filters';
2727
import { getDarkmode } from '@/components/darkmode/darkmode';
2828
import { DefaultCurrencyRotator } from '@/components/rates/rates';
29+
import { RatesContext } from '@/contexts/RatesContext';
2930
import { AppContext, TChartDisplay } from '@/contexts/AppContext';
3031
import styles from './chart.module.css';
3132

@@ -137,6 +138,7 @@ export const Chart = ({
137138

138139
const { t, i18n } = useTranslation();
139140
const { chartDisplay, setChartDisplay } = useContext(AppContext);
141+
const { defaultCurrency } = useContext(RatesContext);
140142
const [searchParams] = useSearchParams();
141143

142144
const ref = useRef<HTMLDivElement>(null);
@@ -163,6 +165,15 @@ export const Chart = ({
163165
toolTipTime: 0,
164166
});
165167

168+
useEffect(() => {
169+
setTooltipData({
170+
toolTipVisible: false,
171+
toolTipTop: 0,
172+
toolTipLeft: 0,
173+
toolTipTime: 0,
174+
});
175+
}, [defaultCurrency]);
176+
166177
const [showAnimationOverlay, setAnimationOverlay] = useState(true);
167178

168179
const prevChartDataDaily = usePrevious(data.chartDataDaily);

0 commit comments

Comments
 (0)