Skip to content

Commit 70ac8d1

Browse files
Merge pull request #26 from cbvora/build_issue
prev next click issue and build issue
2 parents 818ff01 + d32d9f0 commit 70ac8d1

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

app/practice/page.tsx

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,12 @@ const Practice: NextPage = () => {
5353
variables: { link: url },
5454
});
5555

56-
const setThisSeqIntoURL = useCallback(
57-
(seq: number) => {
58-
const newSearchParams = new URLSearchParams(searchParams.toString());
59-
newSearchParams.set("seq", seq.toString());
60-
const newUrl = `${
61-
window.location.pathname
62-
}?${newSearchParams.toString()}`;
63-
router.push(newUrl, { shallow: true });
64-
},
65-
[router, searchParams],
66-
);
56+
const setThisSeqIntoURL = useCallback((seq: number) => {
57+
const newSearchParams = new URLSearchParams(window.location.search);
58+
newSearchParams.set("seq", seq.toString());
59+
const newUrl = `${window.location.pathname}?${newSearchParams.toString()}`;
60+
window.history.replaceState(null, "", newUrl);
61+
}, []);
6762

6863
useEffect(() => {
6964
setCurrentQuestionIndex(seq);

components/QuizForm.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Question } from "./types";
44
import Image from "next/image";
55
import SelectionInput from "./SelectionInput";
66
import { Button } from "./Button";
7-
import NumberInputComponent from "./NumberInputComponent";
7+
// import NumberInputComponent from "./NumberInputComponent";
88
import LoadingIndicator from "./LoadingIndicator";
99

1010
type Props = {
@@ -220,10 +220,22 @@ const QuizForm: FC<Props> = ({
220220
<span className="absolute text-white opacity-10 font-bold text-6xl bottom-0 -z-[1] select-none">
221221
Q&A
222222
</span>
223-
<NumberInputComponent
223+
{/* Debounce rerendering issue on prev next click
224+
<NumberInputComponent
224225
totalQuestions={totalQuestions}
225226
currentQuestionIndex={currentQuestionIndex}
226227
handleNextQuestion={handleNextQuestion}
228+
/> */}
229+
230+
<input
231+
className="w-[40px] text-white rounded-l-md border outline-0 border-slate-700 bg-slate-900 text-center text-md [-moz-appearance:_textfield] [&::-webkit-inner-spin-button]:m-0 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:m-0 [&::-webkit-outer-spin-button]:appearance-none"
232+
type="number"
233+
min={0}
234+
max={totalQuestions}
235+
value={currentQuestionIndex}
236+
onChange={(e) => {
237+
handleNextQuestion(Number(e.target.value));
238+
}}
227239
/>
228240
<p className="text-white text-md font-semibold text-center w-[40px] rounded-r-md border bg-slate-800 border-slate-700">
229241
{totalQuestions}

0 commit comments

Comments
 (0)