Skip to content

Commit 1edaa9e

Browse files
autofocus input by default (#81)
J=CLIP-736 TEST=auto,manual verified that the input box is auto focus on test-site ran `npm run test`
1 parent 1e4b116 commit 1edaa9e

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@yext/chat-ui-react",
3-
"version": "0.11.1",
3+
"version": "0.11.2",
44
"description": "A library of React Components for powering Yext Chat integrations.",
55
"author": "clippy@yext.com",
66
"main": "./lib/commonjs/src/index.js",

src/components/ChatInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export interface ChatInputProps {
8080
export function ChatInput({
8181
placeholder = "Type a message...",
8282
stream = false,
83-
inputAutoFocus = false,
83+
inputAutoFocus = true,
8484
handleError,
8585
sendButtonIcon = <ArrowIcon />,
8686
customCssClasses,

tests/components/ChatInput.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ it("updates text when type in textarea", async () => {
3535
expect(textbox).toHaveDisplayValue("test");
3636
});
3737

38-
it("does not focus on input box by default", async () => {
38+
it("maintains focus on input box by default", async () => {
3939
render(<ChatInput />);
4040
const textbox = screen.getByRole("textbox");
41-
expect(textbox).not.toHaveFocus();
41+
expect(textbox).toHaveFocus();
4242
});
4343

44-
it("maintains focus on input box when inputAutoFocus field is set to true", async () => {
45-
render(<ChatInput inputAutoFocus={true} />);
44+
it("does not focus on input box when inputAutoFocus field is set to false", async () => {
45+
render(<ChatInput inputAutoFocus={false} />);
4646
const textbox = screen.getByRole("textbox");
47-
expect(textbox).toHaveFocus();
47+
expect(textbox).not.toHaveFocus();
4848
});
4949

5050
it("sends request and reset input when click on send button", async () => {

0 commit comments

Comments
 (0)