File tree Expand file tree Collapse file tree 2 files changed +20
-13
lines changed
Expand file tree Collapse file tree 2 files changed +20
-13
lines changed Original file line number Diff line number Diff 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 ) ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { Question } from "./types";
44import Image from "next/image" ;
55import SelectionInput from "./SelectionInput" ;
66import { Button } from "./Button" ;
7- import NumberInputComponent from "./NumberInputComponent" ;
7+ // import NumberInputComponent from "./NumberInputComponent";
88import LoadingIndicator from "./LoadingIndicator" ;
99
1010type 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 }
You can’t perform that action at this time.
0 commit comments