Skip to content

Commit c213373

Browse files
authored
fix(thecurve): fixes for scroll behaviour
1 parent 3498969 commit c213373

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

front_end/src/app/(thecurve)/components/curve_histogram/curve_histogram.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,16 @@ const CurveHistogram: FC<Props> = ({
4141
x: [0, 100],
4242
y: [0, maxY],
4343
}}
44-
containerComponent={<VictoryContainer responsive={true} />}
44+
containerComponent={
45+
<VictoryContainer
46+
responsive={true}
47+
style={{
48+
pointerEvents: "auto",
49+
userSelect: "auto",
50+
touchAction: "auto",
51+
}}
52+
/>
53+
}
4554
padding={{ top: 0, bottom: 25, left: 10, right: 10 }}
4655
height={height}
4756
>

front_end/src/app/(thecurve)/components/curve_histogram/curve_histogram_drawer.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const CurveHistogramDrawer: FC<Props> = ({ postId, onNextQuestion }) => {
2222
const [isLoading, setIsLoading] = useState(true);
2323
const [post, setPost] = useState<PostWithForecasts | null>(null);
2424
const chartContainerRef = useRef<HTMLDivElement>(null);
25+
const nextBtnRef = useRef<HTMLButtonElement>(null);
2526
const [chartHeight, setChartHeight] = useState(65);
2627

2728
useEffect(() => {
@@ -40,6 +41,13 @@ const CurveHistogramDrawer: FC<Props> = ({ postId, onNextQuestion }) => {
4041
useEffect(() => {
4142
if (!chartContainerRef.current) return;
4243
setChartHeight(Math.max(chartContainerRef.current?.clientHeight, 65));
44+
45+
setTimeout(() => {
46+
nextBtnRef.current?.scrollIntoView({
47+
behavior: "smooth",
48+
block: "start",
49+
});
50+
}, 100);
4351
}, [isLoading]);
4452

4553
if (isLoading) {
@@ -93,6 +101,7 @@ const CurveHistogramDrawer: FC<Props> = ({ postId, onNextQuestion }) => {
93101
</div>
94102
<div className="mt-4 flex w-full justify-center">
95103
<Button
104+
ref={nextBtnRef}
96105
className="!bg-blue-900 !px-5 !text-lg !text-gray-200"
97106
onClick={() => {
98107
onNextQuestion && onNextQuestion();

front_end/src/app/(thecurve)/components/curve_survey.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const Survey: FC<Props> = ({ questions }) => {
2020

2121
const nextQuestion = useCallback(
2222
(questionIndex: number) => {
23+
window.scrollTo({ top: 0, behavior: "smooth" });
2324
questions.length === questionIndex + 1
2425
? router.push("/thecurve")
2526
: setQuestionIndex((prev) => (prev ?? 0) + 1);

0 commit comments

Comments
 (0)