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

Fixed Select components initial state. #180

Merged
merged 1 commit into from
Jun 15, 2022
Merged

Conversation

harrymaynard-maximus
Copy link
Contributor

Please check if the PR fulfills these requirements:

  • After these changes, the app was run and still works as expected
  • Tests for these changes were added (if applicable)
  • All existing unit tests were run and still pass

Please specify the type of change this PR introduces (Bug fix, feature addition, content update, chore, etc.):

Additional Notes:

Copy link
Contributor

@bryce-mcmath bryce-mcmath left a comment

Choose a reason for hiding this comment

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

Looks good

Copy link
Contributor

@jlangy jlangy left a comment

Choose a reason for hiding this comment

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

This looks great, just wondering what was breaking using the modelValue directly? Was it that it wasn't null by default? I've used that pattern in a couple of components so want to make sure it doesn't cause some hard to catch bug

@harrymaynard-maximus
Copy link
Contributor Author

The issue was because the <select> element didn't use a v-model, it wouldn't bind the initial null value to the default option. And then there was an issue when selecting a valid option and then selecting the empty option, the empty option wasn't be selected. For some reason it use the option label value instead of the null value. That's why there's the additional logic in the change handler. This might only apply to <select> elements, but it could be worth double checking.

Copy link
Contributor

@stephanieharrison-maximus stephanieharrison-maximus left a comment

Choose a reason for hiding this comment

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

This all looks fine to me.

@jlangy
Copy link
Contributor

jlangy commented Jun 15, 2022

Ah that makes sense. Looks like :value="null" does not act the way I expected, it leaves the value attribute off, which makes sense in hindsight. Looks like then the option falls back to its label if there is no value attribute. I'll make a note to check the DateInput and TimeInput, they use the same syntax. They may be alright since they have processing functions but will add some tests for toggling away and back to the default

@harrymaynard-maximus harrymaynard-maximus merged commit 046a6e5 into v3 Jun 15, 2022
@harrymaynard-maximus harrymaynard-maximus deleted the select-fixes branch June 15, 2022 22:54
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.

4 participants