diff --git a/cypress/integration/behavior/pointer/highlight-selected-with-multiple.html b/cypress/integration/behavior/pointer/highlight-selected-with-multiple.html new file mode 100644 index 00000000..6b8fe0fe --- /dev/null +++ b/cypress/integration/behavior/pointer/highlight-selected-with-multiple.html @@ -0,0 +1,47 @@ + + + + + + + + + + +
+ + + + diff --git a/cypress/integration/behavior/pointer/index.spec.js b/cypress/integration/behavior/pointer/index.spec.js index 0b46c84c..56ad40f5 100644 --- a/cypress/integration/behavior/pointer/index.spec.js +++ b/cypress/integration/behavior/pointer/index.spec.js @@ -18,6 +18,16 @@ context('pointer', () => { cy.get('.vue-dropdown-item').last().should('have.class', 'highlighted') }) + it('should only automaticlly scroll to selected option after open', () => { + cy.visit(path.join(__dirname, 'highlight-selected-with-multiple.html')) + + cy.get('.vue-select').click() + cy.get('.vue-dropdown-item').first().click() + cy.get('.vue-dropdown-item').last().click() + + cy.get('.vue-dropdown-item').last().should('have.class', 'highlighted') + }) + it('should select highlighted item when press enter key', () => { cy.visit(path.join(__dirname, 'with-searchable.html')) diff --git a/src/index.vue b/src/index.vue index 2a81e3d9..f9ecd932 100644 --- a/src/index.vue +++ b/src/index.vue @@ -600,7 +600,8 @@ const VueSelect = { } watch( () => [isFocusing.value, normalized.options, selectedValueSet.value], - () => { + (_, oldValue) => { + if (oldValue?.[0] === true) return if (isFocusing.value === false) return if (normalizedModelValue.value.length === 0) return pointerSet(normalized.options.findIndex(option => selectedValueSet.value.has(normalized.valueBy(option))))