Skip to content

Commit 14f7529

Browse files
committedApr 17, 2025
set focus on renameInput once the modal is opened
1 parent f24bf93 commit 14f7529

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed
 

‎client/modules/IDE/components/SketchListRowBase.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from 'prop-types';
22
import slugify from 'slugify';
3-
import React, { useState, useRef, useCallback } from 'react';
3+
import React, { useState, useEffect, useRef, useCallback } from 'react';
44
import { Link } from 'react-router-dom';
55
import { bindActionCreators } from 'redux';
66
import { connect } from 'react-redux';
@@ -31,10 +31,15 @@ const SketchListRowBase = ({
3131
const [renameValue, setRenameValue] = useState(sketch.name);
3232
const renameInput = useRef(null);
3333

34+
useEffect(() => {
35+
if (renameOpen && renameInput.current) {
36+
renameInput.current.focus();
37+
}
38+
}, [renameOpen]);
39+
3440
const openRename = useCallback(() => {
3541
setRenameOpen(true);
3642
setRenameValue(sketch.name);
37-
renameInput.current.focus();
3843
}, [sketch.name]);
3944

4045
const closeRename = () => setRenameOpen(false);

0 commit comments

Comments
 (0)
Failed to load comments.