Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autofocus input by default #81

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading