Skip to content

fix(select): handle null & undefined as default values #179

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

Merged
merged 3 commits into from
May 31, 2023

Conversation

IcetCode
Copy link
Contributor

fix #178

@netlify
Copy link

netlify bot commented May 31, 2023

Deploy Preview for anu-vue failed.

Name Link
🔨 Latest commit f92a0d2
🔍 Latest deploy log https://app.netlify.com/sites/anu-vue/deploys/6476d9f01a7a5a00080ebb7b

@@ -107,7 +115,7 @@ function middleware() {
ref="selectRef"
readonly
class="a-select-input cursor-pointer"
:value="modelValue.text ?? modelValue"
:value="selectedValueText"
Copy link
Owner

Choose a reason for hiding this comment

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

What if we change it to modelValue ? (modelValue.text ?? modelValue) : undefined

I guess this will probably work the same as the new changes but with less code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep,it can be changed to this, I do this just for readability.

Copy link
Owner

Choose a reason for hiding this comment

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

Hey @IcetCode Can you please use props.modelValue instead of direct use of modelValue for future compatibility in template block? Anu defaults requires using props.x in template block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

like this?

 :value="props.modelValue ? props.modelValue.text ?? props.modelValue : undefined"

Copy link
Owner

Choose a reason for hiding this comment

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

Yes 💯

@jd-solanki jd-solanki changed the title fix(select): correct default value handling fix(select): handle null & undefined as default values May 31, 2023
@jd-solanki jd-solanki merged commit 50c34fe into jd-solanki:main May 31, 2023
@jd-solanki
Copy link
Owner

Thanks 😇

@IcetCode IcetCode deleted the fix/select branch June 13, 2023 06:05
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.

[ASelect]: Component broken when initial value is undefined
2 participants