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: hide dropdown when custom messages are empty #220

Merged
merged 7 commits into from
Mar 31, 2023

Conversation

nohehf
Copy link
Contributor

@nohehf nohehf commented Mar 31, 2023

Closes #219

Summary of major changes

  • Aggregated the messages as optionMessage in a @const
  • Don't show the <li/> element if the optionMessage is empty
  • Renamed add_option_msg_is_active to option_msg_is_active for clarity

Before

image

After

image

Checklist

[ ] has tests for any new functionality or bug fixes -> Not applicable I believe
[ ] has examples/docs for any new functionality -> Not applicable

@janosh
Copy link
Owner

janosh commented Mar 31, 2023

Thanks for the clear explanation and for going straight ahead with the fix. This is a good change! 👍

@janosh janosh enabled auto-merge (squash) March 31, 2023 23:57
@janosh janosh merged commit 2b2eb0d into janosh:main Mar 31, 2023
Copy link
Contributor Author

@nohehf nohehf left a comment

Choose a reason for hiding this comment

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

Thank you for merging @janosh! I left a review on the console.error, lmk what you think.

if (allowUserOptions && !createOptionMsg) {
console.error(
`MultiSelect's allowUserOptions=${allowUserOptions} but createOptionMsg=${createOptionMsg} is falsy. ` +
`This prevents the "Add option" <span> from showing up, resulting in a confusing user experience.`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm a bit surprised by this change. I don't think it should error for this. It is used in the docs and is my use case. A user expects no message if it is set to an empty string.

Copy link
Owner

Choose a reason for hiding this comment

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

Ah, right. Hadn't thought about the tag component use case where you don't necessarily have a pre-defined set of tags.

Maybe we could treat createOptionMsg={null} as a special case to signal you really don't want to show a createOptionMsg so it shouldn't through an error. I still think it would be good to alert devevlopers if they pass createOptionMsg="" or createOptionMsg={undefined} since it might happen by accident.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this sounds like a nice solution! I can open a new MR if you want :)

Copy link
Owner

Choose a reason for hiding this comment

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

That'd be great!

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.

Empty option messages shows an empty line in the dropdown.
2 participants