Skip to content
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/amplify-component-lib",
"version": "10.9.0",
"version": "10.9.1",
"description": "Frontend Typescript components for the Amplify team",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
19 changes: 18 additions & 1 deletion src/molecules/TextField/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { SkeletonBase } from 'src/molecules/Skeleton/SkeletonBase/SkeletonBase';

import styled, { css } from 'styled-components';

export type TextFieldProps = Omit<BaseProps, 'variant'> & {
export type TextFieldProps = Omit<BaseProps, 'variant' | 'inputRef'> & {
Comment thread
mariush2 marked this conversation as resolved.
variant?: Variants;
loading?: boolean;
maxCharacters?: number;
Expand All @@ -41,6 +41,7 @@ interface WrapperProps {

const Wrapper = styled.div<WrapperProps>`
position: relative;
height: fit-content;
input,
textarea {
color: ${colors.text.static_icons__default.rgba};
Expand Down Expand Up @@ -181,6 +182,18 @@ export const TextField: FC<TextFieldProps> = (props) => {
}
};

const handleOnTextFieldRender = (
element: HTMLInputElement | HTMLTextAreaElement | null
) => {
if (
props.maxCharacters &&
element &&
element.value.length !== characterCount
) {
setCharacterCount(element.value.length);
}
};
Comment thread
mariush2 marked this conversation as resolved.

useEffect(() => {
if (
typeof props.value === 'string' &&
Expand All @@ -196,9 +209,13 @@ export const TextField: FC<TextFieldProps> = (props) => {
$variant={usingVariant}
$disabled={props.loading ? false : props.disabled}
$helperRightWidth={helperRightWidth}
style={{
marginBottom: props.helperText ? 0 : `calc(${spacings.small} + 1rem)`,
}}
Comment thread
mariush2 marked this conversation as resolved.
Comment thread
mariush2 marked this conversation as resolved.
>
<Base
{...baseProps}
inputRef={handleOnTextFieldRender}
disabled={props.loading || props.disabled}
onChange={handleOnChange as never} // Bypass TS error caused by union of input and textarea attributes
/>
Expand Down
Loading