Skip to content
Closed
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
5 changes: 5 additions & 0 deletions packages/text-area/src/TextArea/TextArea.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ describe('packages/text-area', () => {
<TextArea label="Some label" />;
<TextArea aria-labelledby="some-id" />;
});

test('TextArea takes a ref for a HTMLTextAreaElement', () => {
const ref = React.createRef<HTMLTextAreaElement>();
render(<TextArea label="Some label" ref={ref} />);
});
});
/* eslint-enable jest/no-disabled-tests */
});
5 changes: 5 additions & 0 deletions packages/text-input/src/TextInput/TextInput.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ describe('packages/text-input', () => {
<TextInput type="search" label="some label" />;
<TextInput type="search" aria-labelledby="some label" />;
});

test('TextInput takes a ref for a HTMLInputElement', () => {
const ref = React.createRef<HTMLInputElement>();
render(<TextInput label="some label" ref={ref} />);
});
});
/* eslint-enable jest/no-disabled-tests */
});
7 changes: 4 additions & 3 deletions packages/text-input/src/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import { textInputStyle } from './TextInput.styles';
import {
SizeVariant,
State,
TextInputComponentType,
TextInputProps,
TextInputType,
} from './TextInput.types';

type TextInput = React.ForwardRefExoticComponent<TextInputProps>;

/**
*
* ```
Expand All @@ -39,7 +40,7 @@ import {
* @param props.sizeVariant determines the size of the text and the height of the input.
*/

const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
const TextInput: TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
(
{
label,
Expand Down Expand Up @@ -182,7 +183,7 @@ const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
</FormField>
);
},
) as TextInputComponentType;
);

TextInput.displayName = 'TextInput';

Expand Down
5 changes: 1 addition & 4 deletions packages/text-input/src/TextInput/TextInput.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ interface TextInputTypeProp {
type?: TextInputType;
}
export interface BaseTextInputProps
extends Omit<React.ComponentPropsWithoutRef<'input'>, AriaLabels>,
extends Omit<React.ComponentPropsWithRef<'input'>, AriaLabels>,
DarkModeProps,
LgIdProps {
/**
Expand Down Expand Up @@ -159,6 +159,3 @@ export type TextInputProps = Either<
BaseTextInputProps & AriaLabelProps & TextInputTypeProp,
AriaLabels
>;

export type TextInputComponentType =
React.ForwardRefExoticComponent<TextInputProps>;
Loading