diff --git a/src/components/Select.vue b/src/components/Select.vue index aebfa26..7f0b3de 100644 --- a/src/components/Select.vue +++ b/src/components/Select.vue @@ -383,7 +383,16 @@ } return newOption } - } + }, + + /** + * When false, updating the options will not reset the select value + * @type {Boolean} + */ + resetOnOptionsChange: { + type: Boolean, + default: true + }, }, data() { @@ -402,7 +411,7 @@ } }, options() { - if (!this.taggable) { + if (!this.taggable && this.resetOnOptionsChange) { this.$set('value', this.multiple ? [] : null) } }, diff --git a/test/unit/coverage/lcov-report/base.css b/test/unit/coverage/lcov-report/base.css index 417c7ad..29737bc 100644 --- a/test/unit/coverage/lcov-report/base.css +++ b/test/unit/coverage/lcov-report/base.css @@ -166,10 +166,13 @@ table.coverage td span.cline-any { /* dark green */ .status-line.high, .high .cover-fill { background:rgb(77,146,33) } .high .chart { border:1px solid rgb(77,146,33) } - - -.medium .chart { border:1px solid #666; } -.medium .cover-fill { background: #666; } +/* dark yellow (gold) */ +.medium .chart { border:1px solid #f9cd0b; } +.status-line.medium, .medium .cover-fill { background: #f9cd0b; } +/* light yellow */ +.medium { background: #fff4c2; } +/* light gray */ +span.cline-neutral { background: #eaeaea; } .cbranch-no { background: yellow !important; color: #111; } @@ -177,8 +180,6 @@ table.coverage td span.cline-any { .fstat-skip { background: #ddd; color: #111 !important; } .cbranch-skip { background: #ddd !important; color: #111; } -span.cline-neutral { background: #eaeaea; } -.medium { background: #eaeaea; } .cover-fill, .cover-empty { display:inline-block; diff --git a/test/unit/specs/Select.spec.js b/test/unit/specs/Select.spec.js index bec61aa..c416654 100644 --- a/test/unit/specs/Select.spec.js +++ b/test/unit/specs/Select.spec.js @@ -752,6 +752,21 @@ describe('Select.vue', () => { }) }) }) + it('should not reset the selected value when the options property changes', (done) => { + const vm = new Vue({ + template: '