Skip to content

Commit

Permalink
fix(theme): support description with a single space using zero-width …
Browse files Browse the repository at this point in the history
…space
  • Loading branch information
iqingting committed Dec 3, 2024
1 parent e8bfdc8 commit 917fbb1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/components/input/src/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ const Input = forwardRef<"input", InputProps>((props, ref) => {
{shouldShowError ? (
<div {...getErrorMessageProps()}>{errorMessage}</div>
) : (
<div {...getDescriptionProps()}>{description}</div>
<div {...getDescriptionProps()}>
{description === " " ? <span>&#8203;</span> : description}
</div>
)}
</div>
);
Expand Down
10 changes: 9 additions & 1 deletion packages/components/input/stories/input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ const MirrorTemplate = (args) => (
</div>
);

const WithDescriptionTemplate = (args) => (
<div className="w-full max-w-4xl flex flex-row items-end gap-4">
<Input {...args} />
<Input {...args} placeholder="Enter your email" />
<Input {...args} description=" " placeholder="Enter your email" />
</div>
);

const FormTemplate = (args) => (
<form
className="w-full max-w-xl flex flex-row items-end gap-4"
Expand Down Expand Up @@ -590,7 +598,7 @@ export const WithoutLabel = {
};

export const WithDescription = {
render: MirrorTemplate,
render: WithDescriptionTemplate,

args: {
...defaultProps,
Expand Down

0 comments on commit 917fbb1

Please sign in to comment.