From 2e1882f784655e672902c981d6b2bbe9073b178b Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 25 Nov 2024 12:03:08 +0200 Subject: [PATCH] fix(question): show hover tooltip for MC and group questions when hide CP toggle is active --- .../multiple_choice_chart_card.tsx | 8 +++++--- .../multiple_choice_group_chart.tsx | 20 ++++++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/front_end/src/app/(main)/questions/[id]/components/detailed_question_card/multiple_choice_chart_card.tsx b/front_end/src/app/(main)/questions/[id]/components/detailed_question_card/multiple_choice_chart_card.tsx index dee02d04f7..4741495af4 100644 --- a/front_end/src/app/(main)/questions/[id]/components/detailed_question_card/multiple_choice_chart_card.tsx +++ b/front_end/src/app/(main)/questions/[id]/components/detailed_question_card/multiple_choice_chart_card.tsx @@ -98,9 +98,11 @@ const MultipleChoiceChartCard: FC = ({ .map(({ choice, values, color }) => ({ choiceLabel: choice, color, - valueLabel: getForecastPctDisplayValue(values[cursorIndex]), + valueLabel: hideCP + ? "-" + : getForecastPctDisplayValue(values[cursorIndex]), })), - [choiceItems, cursorIndex] + [choiceItems, cursorIndex, hideCP] ); const tooltipUserChoices = useMemo(() => { @@ -144,7 +146,7 @@ const MultipleChoiceChartCard: FC = ({ return ( = ({ return { choiceLabel: choice, color, - valueLabel: getQuestionTooltipLabel({ - timestamps: optionTimestamps ?? timestamps, - values, - cursorTimestamp, - closeTime, - question: questions[index], - }), + valueLabel: hideCP + ? "-" + : getQuestionTooltipLabel({ + timestamps: optionTimestamps ?? timestamps, + values, + cursorTimestamp, + closeTime, + question: questions[index], + }), }; } ), - [choiceItems, cursorTimestamp, questions, timestamps] + [choiceItems, cursorTimestamp, hideCP, questions, timestamps] ); const tooltipUserChoices = useMemo(() => { if (!userForecasts) { @@ -208,7 +210,7 @@ const MultipleChoiceGroupChart: FC = ({ return (