Skip to content

Commit

Permalink
Fix text field tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jamdelion committed Jan 28, 2025
1 parent fbfd644 commit 5c61b9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion editor.planx.uk/src/@planx/components/TextInput/Public.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const TextInputComponent: React.FC<Props> = (props) => {

const characterCountLimit = props.type && getTextLimit(props.type);
const displayCharacterCount =
props.type !== TextInputType.Short && characterCountLimit;
Boolean(props.type !== TextInputType.Short && characterCountLimit);

return (
<Card handleSubmit={formik.handleSubmit} isValid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export const TextFieldInput: React.FC<Props<TextField>> = (props) => {
const { id, errorMessage, required, title } = fieldProps;

const characterCountLimit = data.type && getTextLimit(data.type);

const displayCharacterCount = Boolean(
data.type !== TextInputType.Short && characterCountLimit
);

return (
<InputLabel label={title} htmlFor={id}>
{data.description && (
Expand Down Expand Up @@ -45,7 +50,7 @@ export const TextFieldInput: React.FC<Props<TextField>> = (props) => {
.join(" "),
}}
/>
{characterCountLimit && (
{displayCharacterCount && (
<CharacterCounter
textInputType={data.type || TextInputType.Long}
count={fieldProps?.value?.length}
Expand Down

0 comments on commit 5c61b9f

Please sign in to comment.