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

fix(TextField): avoid right helper text from wrapping, fix spacing and aria label for maxCount text when multiline is true #1272

Merged
merged 3 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions src/__screenshot_tests__/input-fields-screenshot-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ test('TextField - multiline and maxLength', async () => {
expect(image).toMatchImageSnapshot();
});

test('TextField - multiline and maxLength with long helperText', async () => {
await openStoryPage({
id: 'components-input-fields-textfield--uncontrolled',
device: 'MOBILE_IOS',
args: {
defaultValue: '',
maxLength: true,
multiline: true,
helperText: 'This is a very long helper text to test that the maxLength text is not wrapping',
},
});

const fieldWrapper = await screen.findByTestId('text-field');
const image = await fieldWrapper.screenshot();

expect(image).toMatchImageSnapshot();
});

test('TextField - long label', async () => {
await openStoryPage({
id: 'components-input-fields-textfield--uncontrolled',
Expand Down
2 changes: 2 additions & 0 deletions src/text-field-components.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ export const leftHelperText = style([
},
]);

export const rightHelperText = sprinkles({paddingLeft: 16});
Copy link
Collaborator Author

@marcoskolodny marcoskolodny Oct 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid this issue:

Screenshot from 2024-10-18 15-27-18

Specs:

image


export const helperText = sprinkles({
flexGrow: 1,
paddingTop: 4,
Expand Down
4 changes: 2 additions & 2 deletions src/text-field-components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ export const HelperText = ({leftText, rightText, error, id}: HelperTextProps): J
</p>
)}
{rightText && (
<div className={classnames(styles.helperText)}>
<Text1 color={rightColor} regular as="p" textAlign="right">
<div className={classnames(styles.helperText, {[styles.rightHelperText]: !!leftText})}>
<Text1 color={rightColor} regular as="p" textAlign="right" wordBreak={false}>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before/after:

input-fields-screenshot-test-tsx-text-field-multiline-and-max-length-with-long-helper-text-1-diff

{rightText}
</Text1>
</div>
Expand Down
Loading