Skip to content

Commit

Permalink
refactor: scroll.ts 유틸함수 > refObject.ts 로 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
YuHyun-P committed Dec 13, 2023
1 parent 79dbec2 commit 6e7165d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
5 changes: 2 additions & 3 deletions packages/frontend/src/pages/quizzes/[id].page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import {
} from "../../reducers/terminalReducer";
import { Categories, Quiz, QuizGitGraphCommit } from "../../types/quiz";
import { TerminalContentType } from "../../types/terminalType";
import { focusRef } from "../../utils/refObject";
import { scrollIntoView } from "../../utils/scroll";
import { focusRef, scrollIntoViewRef } from "../../utils/refObject";
import { isString } from "../../utils/typeGuard";

import * as styles from "./quiz.css";
Expand Down Expand Up @@ -132,7 +131,7 @@ export default function QuizPage({ quiz }: { quiz: Quiz }) {
}, [id]);

useEffect(() => {
scrollIntoView(terminalInputRef);
scrollIntoViewRef(terminalInputRef);
clearTextContent(terminalInputRef);
focusRef(terminalInputRef);
}, [contentArray]);
Expand Down
4 changes: 4 additions & 0 deletions packages/frontend/src/utils/refObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ import { RefObject } from "react";
export function focusRef<T extends HTMLOrSVGElement>(ref: RefObject<T>) {
ref.current?.focus();
}

export function scrollIntoViewRef<T extends Element>(ref: RefObject<T>) {
ref.current?.scrollIntoView();
}
10 changes: 0 additions & 10 deletions packages/frontend/src/utils/scroll.ts

This file was deleted.

0 comments on commit 6e7165d

Please sign in to comment.