@copilotkit/react-core 0.0.0-main-20260403195251 → 0.0.0-main-20260406172622

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copilotkit/react-core",
3
- "version": "0.0.0-main-20260403195251",
3
+ "version": "0.0.0-main-20260406172622",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "ai",
@@ -64,11 +64,11 @@
64
64
  "tw-animate-css": "^1.3.5",
65
65
  "untruncate-json": "^0.0.1",
66
66
  "use-stick-to-bottom": "^1.1.1",
67
- "@copilotkit/a2ui-renderer": "0.0.0-main-20260403195251",
68
- "@copilotkit/core": "0.0.0-main-20260403195251",
69
- "@copilotkit/runtime-client-gql": "0.0.0-main-20260403195251",
70
- "@copilotkit/shared": "0.0.0-main-20260403195251",
71
- "@copilotkit/web-inspector": "0.0.0-main-20260403195251"
67
+ "@copilotkit/a2ui-renderer": "0.0.0-main-20260406172622",
68
+ "@copilotkit/core": "0.0.0-main-20260406172622",
69
+ "@copilotkit/runtime-client-gql": "0.0.0-main-20260406172622",
70
+ "@copilotkit/shared": "0.0.0-main-20260406172622",
71
+ "@copilotkit/web-inspector": "0.0.0-main-20260406172622"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@tailwindcss/cli": "^4.1.11",
@@ -96,7 +96,7 @@
96
96
  "valibot": "^1.2.0",
97
97
  "vitest": "^3.2.4",
98
98
  "zod": ">=3.0.0",
99
- "tsconfig": "0.0.0-main-20260403195251"
99
+ "tsconfig": "0.0.0-main-20260406172622"
100
100
  },
101
101
  "peerDependencies": {
102
102
  "react": "^18 || ^19 || ^19.0.0-rc",
@@ -125,7 +125,7 @@ export function CopilotChatInput({
125
125
  onChange,
126
126
  value,
127
127
  toolsMenu,
128
- autoFocus = true,
128
+ autoFocus = false,
129
129
  positioning = "static",
130
130
  keyboardHeight = 0,
131
131
  containerRef,
@@ -252,7 +252,7 @@ export function CopilotChatInput({
252
252
  }
253
253
 
254
254
  if (config?.isModalOpen && !previousModalStateRef.current) {
255
- inputRef.current?.focus();
255
+ inputRef.current?.focus({ preventScroll: true });
256
256
  }
257
257
 
258
258
  previousModalStateRef.current = config?.isModalOpen;
@@ -1222,25 +1222,9 @@ export namespace CopilotChatInput {
1222
1222
  () => internalTextareaRef.current as HTMLTextAreaElement,
1223
1223
  );
1224
1224
 
1225
- // Auto-scroll input into view on mobile when focused
1226
- useEffect(() => {
1227
- const textarea = internalTextareaRef.current;
1228
- if (!textarea) return;
1229
-
1230
- const handleFocus = () => {
1231
- // Small delay to let the keyboard start appearing
1232
- setTimeout(() => {
1233
- textarea.scrollIntoView({ behavior: "smooth", block: "nearest" });
1234
- }, 300);
1235
- };
1236
-
1237
- textarea.addEventListener("focus", handleFocus);
1238
- return () => textarea.removeEventListener("focus", handleFocus);
1239
- }, []);
1240
-
1241
1225
  useEffect(() => {
1242
1226
  if (autoFocus) {
1243
- internalTextareaRef.current?.focus();
1227
+ internalTextareaRef.current?.focus({ preventScroll: true });
1244
1228
  }
1245
1229
  }, [autoFocus]);
1246
1230
 
@@ -983,4 +983,50 @@ describe("CopilotChatInput", () => {
983
983
  expect(mockOnSubmitMessage).toHaveBeenCalledWith("test message");
984
984
  });
985
985
  });
986
+
987
+ describe("Scroll behavior", () => {
988
+ it("does not call scrollIntoView when the textarea receives focus", async () => {
989
+ const scrollIntoViewMock = vi.fn();
990
+ HTMLElement.prototype.scrollIntoView = scrollIntoViewMock;
991
+
992
+ renderWithProvider(
993
+ <CopilotChatInput autoFocus onSubmitMessage={mockOnSubmitMessage} />,
994
+ );
995
+
996
+ const textarea = screen.getByRole("textbox");
997
+
998
+ // Trigger focus explicitly (autoFocus also triggers it, but let's be explicit)
999
+ fireEvent.focus(textarea);
1000
+
1001
+ // Wait long enough for the 300ms setTimeout inside the focus handler
1002
+ await new Promise((resolve) => setTimeout(resolve, 500));
1003
+
1004
+ expect(scrollIntoViewMock).not.toHaveBeenCalled();
1005
+
1006
+ // Clean up
1007
+ delete (HTMLElement.prototype as any).scrollIntoView;
1008
+ });
1009
+
1010
+ it("does not auto-focus the textarea by default", () => {
1011
+ const focusSpy = vi.spyOn(HTMLElement.prototype, "focus");
1012
+
1013
+ renderWithProvider(
1014
+ <CopilotChatInput onSubmitMessage={mockOnSubmitMessage} />,
1015
+ );
1016
+
1017
+ expect(focusSpy).not.toHaveBeenCalled();
1018
+ focusSpy.mockRestore();
1019
+ });
1020
+
1021
+ it("auto-focuses with preventScroll when autoFocus is true", () => {
1022
+ const focusSpy = vi.spyOn(HTMLElement.prototype, "focus");
1023
+
1024
+ renderWithProvider(
1025
+ <CopilotChatInput autoFocus onSubmitMessage={mockOnSubmitMessage} />,
1026
+ );
1027
+
1028
+ expect(focusSpy).toHaveBeenCalledWith({ preventScroll: true });
1029
+ focusSpy.mockRestore();
1030
+ });
1031
+ });
986
1032
  });