mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-19 01:21:30 +03:00
Scroll to currently softfocus cell (#1008)
* - scroll to currently softfocus cell * - moved useEffect to CellSoftFocus component
This commit is contained in:
parent
f111440e00
commit
700b567320
@ -1,8 +1,10 @@
|
|||||||
|
import { Ref } from 'react';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
softFocus?: boolean;
|
softFocus?: boolean;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
|
scrollRef?: Ref<HTMLDivElement>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const EditableCellDisplayModeOuterContainer = styled.div<
|
export const EditableCellDisplayModeOuterContainer = styled.div<
|
||||||
@ -37,6 +39,7 @@ export function EditableCellDisplayContainer({
|
|||||||
children,
|
children,
|
||||||
softFocus,
|
softFocus,
|
||||||
onClick,
|
onClick,
|
||||||
|
scrollRef,
|
||||||
}: React.PropsWithChildren<Props>) {
|
}: React.PropsWithChildren<Props>) {
|
||||||
return (
|
return (
|
||||||
<EditableCellDisplayModeOuterContainer
|
<EditableCellDisplayModeOuterContainer
|
||||||
@ -47,6 +50,7 @@ export function EditableCellDisplayContainer({
|
|||||||
}
|
}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
softFocus={softFocus}
|
softFocus={softFocus}
|
||||||
|
ref={scrollRef}
|
||||||
>
|
>
|
||||||
<EditableCellDisplayModeInnerContainer>
|
<EditableCellDisplayModeInnerContainer>
|
||||||
{children}
|
{children}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { PropsWithChildren } from 'react';
|
import { PropsWithChildren, useEffect, useRef } from 'react';
|
||||||
|
|
||||||
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||||
import { isNonTextWritingKey } from '@/ui/utilities/hotkey/utils/isNonTextWritingKey';
|
import { isNonTextWritingKey } from '@/ui/utilities/hotkey/utils/isNonTextWritingKey';
|
||||||
@ -13,6 +13,12 @@ type OwnProps = PropsWithChildren<unknown>;
|
|||||||
export function EditableCellSoftFocusMode({ children }: OwnProps) {
|
export function EditableCellSoftFocusMode({ children }: OwnProps) {
|
||||||
const { openEditableCell } = useEditableCell();
|
const { openEditableCell } = useEditableCell();
|
||||||
|
|
||||||
|
const scrollRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
scrollRef.current?.scrollIntoView({ block: 'nearest' });
|
||||||
|
});
|
||||||
|
|
||||||
function openEditMode() {
|
function openEditMode() {
|
||||||
openEditableCell();
|
openEditableCell();
|
||||||
}
|
}
|
||||||
@ -52,7 +58,11 @@ export function EditableCellSoftFocusMode({ children }: OwnProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EditableCellDisplayContainer onClick={handleClick} softFocus>
|
<EditableCellDisplayContainer
|
||||||
|
onClick={handleClick}
|
||||||
|
softFocus
|
||||||
|
scrollRef={scrollRef}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</EditableCellDisplayContainer>
|
</EditableCellDisplayContainer>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user