Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 12a4def

Browse files
committed
onFocus whe3n click
1 parent 58fc7f0 commit 12a4def

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/components/Cell.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default function DefaultCell(cellProperties: Cell) {
2222
const note: NoteInfo = (cellProperties.row.original as any).note;
2323
/** Ref to cell container */
2424
const containerCellRef = useRef<HTMLDivElement>();
25+
const editableMdRef = useRef<HTMLInputElement>();
2526
/** state of cell value */
2627
const [contextValue, setContextValue] = useState({
2728
value: initialValue,
@@ -44,6 +45,12 @@ export default function DefaultCell(cellProperties: Cell) {
4445
}
4546
}, []);
4647

48+
useEffect(() => {
49+
if (editableMdRef.current) {
50+
editableMdRef.current.focus();
51+
}
52+
}, [editableMdRef, dirtyCell]);
53+
4754
useEffect(() => {
4855
if (!dirtyCell && containerCellRef.current) {
4956
//TODO - this is a hack. find why is layout effect called twice
@@ -116,6 +123,7 @@ export default function DefaultCell(cellProperties: Cell) {
116123
onKeyDown={handleKeyDown}
117124
onBlur={handlerEditableOnBlur}
118125
className={"data-input"}
126+
ref={editableMdRef}
119127
/>
120128
) : (
121129
<span

0 commit comments

Comments
 (0)