nvms / vue-atlas

A Vue.js 2 UI component library.
MIT License
180 stars 22 forks source link

VaSelect errors out if `multiple` flag is set and the model is undefined. #165

Closed jsdbroughton closed 4 years ago

jsdbroughton commented 4 years ago

What version of vue-atlas are you using? v2.16

Steps to reproduce:

  1. Instance a VaSelect component
  2. set v-model to an undefined variable
  3. add the multiple flag

What is expected? Select and Options to populate as expected.

What is actually happening?

TypeError: Cannot read property 'length' of undefined at Proxy.VaSelectvue_type_template_id_482a76e8_scoped_true_render

If any of the referenced models are not defined on that object as either string or [] and the multiple flag is set, the component doesn't render.

Any additional comments? (optional) I only discovered this when moving all the form item models into a single object.

There are two fixes:

  1. [Model] document that models must be defined for component to render
  2. [Select] add a definition check prior to the length check in the <button> render:

:class="[`va-dropdown-toggle`, `va-select-btn`, showSelected && multiple` && typeof value !== undefined `` && value.length ?va-select-multiple: '', show ?va-select-btn-open` : '']"


[VaSelect.vue L4](https://github.com/nvms/vue-atlas/blob/master/src/Select/VaSelect.vue#L4)
Githubissues.
  • Githubissues is a development platform for aggregating issues.