Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Select): display label for empty string value #543

Merged
merged 4 commits into from
Feb 12, 2025
Merged

Conversation

ariser
Copy link
Collaborator

@ariser ariser commented Feb 12, 2025

Resolves #490

Why

Putting empty string as a value of Select.Item results in an empty Select:
image

What

The value prop of SingleSelectValue is typed as required. Also by usage, it gets rendered only when selectedValues array is not empty. Thus in normal circumstances it can't be undefined or null. Seems like the emptiness check just causes the bug while not doing anything else.

@ariser ariser requested review from rndD and vineethasok February 12, 2025 13:30
Copy link

vercel bot commented Feb 12, 2025

You must have Developer access to commit code to ClickHouse on Vercel. If you contact an administrator and receive Developer access, commit again to see your changes.

Learn more: https://vercel.com/docs/accounts/team-members-and-roles/access-roles#team-level-roles

@@ -21,9 +21,6 @@ const SingleSelectValue = ({
value: string;
}) => {
const { icon, iconDir, children, label } = valueNode ?? {};
if (!value) {
return null;
}
Copy link
Contributor

@rndD rndD Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we have it, tho? What was the case for this if?

Copy link
Collaborator Author

@ariser ariser Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was initially there after the major refactoring: #137

I don't see a reason for it. The tests are green.
@vineethasok do you remember if there is a specific case for this check?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was inorder to not have any content at all when value is empty and not render the IconContainer component
If it is not causing any issue we can remove it but I added this for this reason

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an empty string is a valid value, and we should treat it as any other string
I can keep check for undefined and null though, if you think it's needed. As of now, I don't see a way to pass these values here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you know what, I'll keep the check for undefined, it just makes sense

Copy link

vercel bot commented Feb 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
click-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 12, 2025 4:59pm

item && fireEvent.click(item);
expect(selectTrigger.textContent).toBe(OPTION_TEXT);
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@ariser ariser merged commit 3657279 into main Feb 12, 2025
6 checks passed
@ariser ariser deleted the nick_fix-select-value branch February 12, 2025 17:02
@rndD rndD mentioned this pull request Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Select: component doesn't show label if value is empty string
3 participants