Files
twenty_crm/packages/twenty-front/src/modules/ui/input/hooks/useInputFocusWithoutScrollOnMount.ts
2024-09-18 10:35:13 +02:00

15 lines
345 B
TypeScript

import { useEffect, useRef } from 'react';
import { isDefined } from 'twenty-ui';
export const useInputFocusWithoutScrollOnMount = () => {
const inputRef = useRef<HTMLInputElement>(null);
useEffect(() => {
if (isDefined(inputRef.current)) {
inputRef.current.focus({ preventScroll: true });
}
});
return { inputRef };
};