From da3f4f3fc76548d37127dc15dfb6a8f5d67f1a51 Mon Sep 17 00:00:00 2001 From: Rishi Date: Sun, 4 Feb 2024 23:50:22 +0530 Subject: [PATCH] Fix : [#2986] Add ref callback --- .../CollectionList/CollectionListRow.jsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/client/modules/IDE/components/CollectionList/CollectionListRow.jsx b/client/modules/IDE/components/CollectionList/CollectionListRow.jsx index dafbe21517..457be3601b 100644 --- a/client/modules/IDE/components/CollectionList/CollectionListRow.jsx +++ b/client/modules/IDE/components/CollectionList/CollectionListRow.jsx @@ -55,9 +55,6 @@ const CollectionListRowBase = (props) => { closeAll(); setRenameOpen(true); setRenameValue(props.collection.name); - if (renameInput.current) { - renameInput.current.focus(); - } }; const handleRenameChange = (e) => { @@ -71,6 +68,12 @@ const CollectionListRowBase = (props) => { } }; + const handleRenameFocus = () => { + if (renameInput.current) { + renameInput.current.focus(); + } + }; + const handleRenameBlur = () => { updateName(); closeAll(); @@ -116,7 +119,10 @@ const CollectionListRowBase = (props) => { onKeyUp={handleRenameEnter} onBlur={handleRenameBlur} onClick={(e) => e.stopPropagation()} - ref={renameInput} + ref={(node) => { + renameInput.current = node; + handleRenameFocus(); + }} /> )}