Skip to content

Commit

Permalink
autofocus input by default (#81)
Browse files Browse the repository at this point in the history
J=CLIP-736
TEST=auto,manual

verified that the input box is auto focus on test-site
ran `npm run test`
  • Loading branch information
anguyen-yext2 authored Jul 10, 2024
1 parent 1e4b116 commit 1edaa9e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yext/chat-ui-react",
"version": "0.11.1",
"version": "0.11.2",
"description": "A library of React Components for powering Yext Chat integrations.",
"author": "[email protected]",
"main": "./lib/commonjs/src/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/components/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export interface ChatInputProps {
export function ChatInput({
placeholder = "Type a message...",
stream = false,
inputAutoFocus = false,
inputAutoFocus = true,
handleError,
sendButtonIcon = <ArrowIcon />,
customCssClasses,
Expand Down
10 changes: 5 additions & 5 deletions tests/components/ChatInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ it("updates text when type in textarea", async () => {
expect(textbox).toHaveDisplayValue("test");
});

it("does not focus on input box by default", async () => {
it("maintains focus on input box by default", async () => {
render(<ChatInput />);
const textbox = screen.getByRole("textbox");
expect(textbox).not.toHaveFocus();
expect(textbox).toHaveFocus();
});

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

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

0 comments on commit 1edaa9e

Please sign in to comment.