diff --git a/Composer/packages/client/src/pages/design/exportSkillModal/content/AddCallers.tsx b/Composer/packages/client/src/pages/design/exportSkillModal/content/AddCallers.tsx index c4eb0c53b7..587079aba8 100644 --- a/Composer/packages/client/src/pages/design/exportSkillModal/content/AddCallers.tsx +++ b/Composer/packages/client/src/pages/design/exportSkillModal/content/AddCallers.tsx @@ -52,7 +52,7 @@ const BorderlessTextField: React.FC = (props) => { if (componentFocusOnMount) { fieldRef.current?.focus(); } - }, []); + }, [componentFocusOnMount]); return ( = ({ projectId, callers, onUpdat }; const handleAddNewAllowedCallerClick = () => { const currentCallers = callers.slice(); - currentCallers?.push(''); - onUpdateCallers(currentCallers); - setFocusCallerIndex(currentCallers.length - 1); + const index = currentCallers.findIndex((content) => content === ''); + if (index < 0) { + currentCallers?.push(''); + onUpdateCallers(currentCallers); + setFocusCallerIndex(currentCallers.length - 1); + } else { + // just focus on the first empty caller. + setFocusCallerIndex(index); + } }; const [focusCallerIndex, setFocusCallerIndex] = useState(0);