Skip to content

Commit

Permalink
fix: Extend clickable area of Prompt Input (#3299)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorlanigan authored Feb 18, 2025
1 parent 6b9200b commit 0906374
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/prompt-input/__tests__/prompt-input.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import PromptInput, { PromptInputProps } from '../../../lib/components/prompt-in
import createWrapper from '../../../lib/components/test-utils/dom';
import PromptInputWrapper from '../../../lib/components/test-utils/dom/prompt-input';

import styles from '../../../lib/components/prompt-input/styles.selectors.js';

jest.mock('@cloudscape-design/component-toolkit', () => ({
...jest.requireActual('@cloudscape-design/component-toolkit'),
useContainerQuery: () => [800, () => {}],
Expand Down Expand Up @@ -305,6 +307,17 @@ describe('secondary actions', () => {
});
});

test('clicking the area between secondary actions and action button should focus the component', () => {
const { wrapper } = renderPromptInput({
value: '',
secondaryActions: 'secondary actions',
});

wrapper.find(`.${styles.buffer}`)!.click();

expect(wrapper.findNativeTextarea().getElement()).toHaveFocus();
});

describe('secondary content', () => {
test('should render correct text in secondary content slot', () => {
const { wrapper } = renderPromptInput({
Expand Down
1 change: 1 addition & 0 deletions src/prompt-input/internal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ const InternalPromptInput = React.forwardRef(
})}
>
{secondaryActions}
<div className={styles.buffer} onClick={() => textareaRef.current?.focus()} />
{hasActionButton && action}
</div>
)}
Expand Down
6 changes: 6 additions & 0 deletions src/prompt-input/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,9 @@ $invalid-border-offset: constants.$invalid-control-left-padding;
padding-block-end: awsui.$space-scaled-xxs;
}
}

.buffer {
flex: 1;
align-self: stretch;
cursor: text;
}

0 comments on commit 0906374

Please sign in to comment.