Skip to content

Commit 8162909

Browse files
authored
Merge pull request #2988 from Ri-Sharma/Issue#2986
Fix : [#2986] Add ref callback
2 parents d497382 + aa439b3 commit 8162909

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

client/modules/IDE/components/CollectionList/CollectionListRow.jsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,6 @@ const CollectionListRowBase = (props) => {
129129
closeAll();
130130
setRenameOpen(true);
131131
setRenameValue(props.collection.name);
132-
if (renameInput.current) {
133-
renameInput.current.focus();
134-
}
135132
};
136133

137134
const handleRenameChange = (e) => {
@@ -146,6 +143,12 @@ const CollectionListRowBase = (props) => {
146143
}
147144
};
148145

146+
const handleRenameFocus = () => {
147+
if (renameInput.current) {
148+
renameInput.current.focus();
149+
}
150+
};
151+
149152
const handleRenameBlur = () => {
150153
updateName();
151154
closeAll();
@@ -191,7 +194,10 @@ const CollectionListRowBase = (props) => {
191194
onKeyDown={handleRenameEnter}
192195
onBlur={handleRenameBlur}
193196
onClick={(e) => e.stopPropagation()}
194-
ref={renameInput}
197+
ref={(node) => {
198+
renameInput.current = node;
199+
handleRenameFocus();
200+
}}
195201
/>
196202
)}
197203
</>

0 commit comments

Comments
 (0)