Skip to content

Commit 0eae244

Browse files
committed
[#143] fix: focusId 설정
- insert할 id위치 찾아주기
1 parent e9b3b7e commit 0eae244

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

frontend/src/components/molecules/BlockHandler/BlockHandler.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ReactComponent as DraggableIcon } from '@assets/draggable.svg';
77
import { ReactComponent as PlusIcon } from '@assets/plus.svg';
88
import { useSetRecoilState } from 'recoil';
99

10-
import { draggingBlockState, modalState } from '@/stores';
10+
import { draggingBlockState, modalState, focusState } from '@/stores';
1111
import { Block } from '@/schemes';
1212

1313
const buttonWrapperCss = () => css`
@@ -39,6 +39,7 @@ interface Props {
3939
function BlockHandler({ blockDTO, blockComponentRef }: Props): JSX.Element {
4040
const setDraggingBlock = useSetRecoilState(draggingBlockState);
4141
const setModal = useSetRecoilState(modalState);
42+
const setFocus = useSetRecoilState(focusState);
4243

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

5152
const handleModal = (event: React.MouseEvent) => {
53+
setFocus(blockDTO.id);
5254
setModal({
5355
isOpen: true,
5456
top: event.clientY,
5557
left: event.clientX,
56-
caretOffset: 0,
58+
caretOffset: blockDTO.value.length + 1,
5759
blockId: blockDTO.id,
5860
});
5961
};

0 commit comments

Comments
 (0)