diff --git a/src/components/shared/Buttons/IconButton.tsx b/src/components/shared/Buttons/IconButton.tsx index d67e15b..ee71406 100644 --- a/src/components/shared/Buttons/IconButton.tsx +++ b/src/components/shared/Buttons/IconButton.tsx @@ -9,7 +9,7 @@ const IconButton = ({ }: ButtonProps) => { const btnClasses = clsx(`button-${variant?.toLowerCase()}`, className); return ( - ); diff --git a/src/lib.tsx b/src/lib.tsx index 3d09b11..09cf9d8 100644 --- a/src/lib.tsx +++ b/src/lib.tsx @@ -24,6 +24,7 @@ class GooeyEmbedFactory { } const innerDiv = document.createElement("div"); innerDiv.style.display = "contents"; + innerDiv.className = "inner-div"; if(targetElem.children.length > 0) targetElem.removeChild(targetElem.children[0]); targetElem.appendChild(innerDiv); const root = renderCopilotChatWidget(innerDiv, config); diff --git a/src/widgets/copilot/components/widget/index.tsx b/src/widgets/copilot/components/widget/index.tsx index 0fb6e7c..eeb3221 100644 --- a/src/widgets/copilot/components/widget/index.tsx +++ b/src/widgets/copilot/components/widget/index.tsx @@ -22,7 +22,8 @@ const CopilotWidget: FC = ({ isInline }) => { const handleEditClick = () => { cancelApiCall(); flushData(); - const ele = document.getElementById(CHAT_INPUT_ID); + const shadowRoot = document.getElementById(isInline ? "inline" : "popup")?.getElementsByClassName("inner-div")[0]?.shadowRoot; + const ele = shadowRoot?.getElementById(CHAT_INPUT_ID); ele?.focus(); }; diff --git a/src/widgets/index.tsx b/src/widgets/index.tsx index 6d83ce8..7938b95 100644 --- a/src/widgets/index.tsx +++ b/src/widgets/index.tsx @@ -37,7 +37,7 @@ export function CopilotChatWidget({ config }: { config?: any }) { } export function renderCopilotChatWidget(elem: Element, config?: any) { - const shadow = elem.attachShadow({ mode: "open" }); + const shadow = elem.attachShadow({ mode: "open", delegatesFocus: true}); const root = ReactDOM.createRoot(shadow); root.render(