Fixes resetting of scroll position in RecordShowPage due to opening of some dropdowns (#6890) (#6906)

fixes #6890

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
Faisal-imtiyaz123
2024-09-18 14:05:13 +05:30
committed by GitHub
parent 601e15f028
commit 72ab6bcf35
6 changed files with 35 additions and 25 deletions

View File

@ -0,0 +1,14 @@
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 };
};