This commit is contained in:
focp212@naver.com
2025-11-07 12:37:12 +09:00
7 changed files with 155 additions and 128 deletions

View File

@@ -18,7 +18,7 @@ export const useKeyboardAware = (options?: UseKeyboardAwareOptions) => {
const [keyboardHeight, setKeyboardHeight] = useState<number>(0);
useEffect(() => {
let focusedElement: HTMLInputElement | null = null;
let focusedElement: HTMLElement | null = null;
let isKeyboardOpen = false;
// 네이티브에서 호출할 전역 함수 등록
@@ -44,7 +44,7 @@ export const useKeyboardAware = (options?: UseKeyboardAwareOptions) => {
};
// focus된 요소를 추적하기 위한 함수
(window as any).setFocusedElement = (element: HTMLInputElement) => {
(window as any).setFocusedElement = (element: HTMLElement) => {
focusedElement = element;
// 키보드가 이미 열려있으면 즉시 스크롤
@@ -62,8 +62,8 @@ export const useKeyboardAware = (options?: UseKeyboardAwareOptions) => {
};
}, []);
// 모든 input에서 사용할 공통 핸들러
const handleInputFocus = (e: React.FocusEvent<HTMLInputElement>) => {
// input과 textarea 모두에서 사용할 공통 핸들러
const handleInputFocus = (e: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => {
// focus된 요소를 저장
(window as any).setFocusedElement?.(e.target);
};