Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

Commit

Permalink
Do not pass 'helperText' down to 'TextInput'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozef Marko authored and wtrocki committed Sep 2, 2022
1 parent c8d452a commit d887ec0
Show file tree
Hide file tree
Showing 4 changed files with 1,190 additions and 1,146 deletions.
8 changes: 8 additions & 0 deletions __tests__/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ test('<TextField> - renders a label', () => {
);
});

test('<TextField> - renders a help', () => {
const element = <TextField required={false} name="x" helperText="y"/>;
const wrapper = mount(element, createContext({ x: { type: String } }));

expect(wrapper.find('div.pf-c-form__helper-text')).toHaveLength(1);
expect(wrapper.find('div.pf-c-form__helper-text').text()).toBe('y');
});

test('<TextField> - renders a wrapper with unknown props', () => {
const element = <TextField name="x" data-x="x" data-y="y" data-z="z" />;
const wrapper = mount(element, createContext({ x: { type: String } }));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uniforms-patternfly",
"version": "4.7.5",
"version": "4.7.6",
"description": "Patternfly forms for uniforms",
"repository": "[email protected]:aerogear/uniforms-patternfly.git",
"author": "Gianluca <[email protected]>",
Expand Down
6 changes: 5 additions & 1 deletion src/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type TextFieldProps = {
disabled: boolean;
error?: boolean;
errorMessage?: string;
helperText?: string;
field?: { format: string };
} & Omit<TextInputProps, 'isDisabled'>;

Expand Down Expand Up @@ -114,6 +115,9 @@ const Text = (props: TextFieldProps) => {
[props.disabled, props.onChange]
);

// https://github.com/aerogear/uniforms-patternfly/issues/106
const {helperText, ...withoutHelperTextProps} = props;

return wrapField(
props,
props.type === 'date' || props.field?.format === 'date' ? (
Expand Down Expand Up @@ -168,7 +172,7 @@ const Text = (props: TextFieldProps) => {
ref={props.inputRef}
type={props.type ?? 'text'}
value={props.value ?? ''}
{...filterDOMProps(props)}
{...filterDOMProps(withoutHelperTextProps)}
/>
)
);
Expand Down
Loading

0 comments on commit d887ec0

Please sign in to comment.