Skip to content

Commit

Permalink
[#143] fix: focusId 설정
Browse files Browse the repository at this point in the history
- insert할 id위치 찾아주기
  • Loading branch information
YiSoJeong committed Dec 19, 2020
1 parent e9b3b7e commit 0eae244
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ReactComponent as DraggableIcon } from '@assets/draggable.svg';
import { ReactComponent as PlusIcon } from '@assets/plus.svg';
import { useSetRecoilState } from 'recoil';

import { draggingBlockState, modalState } from '@/stores';
import { draggingBlockState, modalState, focusState } from '@/stores';
import { Block } from '@/schemes';

const buttonWrapperCss = () => css`
Expand Down Expand Up @@ -39,6 +39,7 @@ interface Props {
function BlockHandler({ blockDTO, blockComponentRef }: Props): JSX.Element {
const setDraggingBlock = useSetRecoilState(draggingBlockState);
const setModal = useSetRecoilState(modalState);
const setFocus = useSetRecoilState(focusState);

const dragStartHandler = (event: React.DragEvent<HTMLDivElement>) => {
event.dataTransfer.effectAllowed = 'move';
Expand All @@ -49,11 +50,12 @@ function BlockHandler({ blockDTO, blockComponentRef }: Props): JSX.Element {
};

const handleModal = (event: React.MouseEvent) => {
setFocus(blockDTO.id);
setModal({
isOpen: true,
top: event.clientY,
left: event.clientX,
caretOffset: 0,
caretOffset: blockDTO.value.length + 1,
blockId: blockDTO.id,
});
};
Expand Down

0 comments on commit 0eae244

Please sign in to comment.