|
1 | 1 | import { expect } from '@vaadin/chai-plugins'; |
2 | | -import { resetMouse, sendKeys, sendMouse } from '@vaadin/test-runner-commands'; |
3 | | -import { fixtureSync, keyboardEventFor, nextRender } from '@vaadin/testing-helpers'; |
| 2 | +import { resetMouse, sendKeys, sendMouse, sendMouseToElement } from '@vaadin/test-runner-commands'; |
| 3 | +import { fixtureSync, keyboardEventFor, nextRender, oneEvent } from '@vaadin/testing-helpers'; |
4 | 4 | import sinon from 'sinon'; |
5 | 5 | import '../src/vaadin-multi-select-combo-box.js'; |
6 | 6 | import { getAllItems, getDataProvider, getFirstItem } from './helpers.js'; |
@@ -203,6 +203,44 @@ describe('selecting items', () => { |
203 | 203 | expect(comboBox.filter).to.equal('an'); |
204 | 204 | expect(inputElement.value).to.equal('an'); |
205 | 205 | }); |
| 206 | + |
| 207 | + it('should not select item when clicked during closing animation', async () => { |
| 208 | + const overlay = comboBox.$.overlay; |
| 209 | + const style = document.createElement('style'); |
| 210 | + style.textContent = ` |
| 211 | + :host([closing]) { |
| 212 | + animation: 200ms closing-animation; |
| 213 | + } |
| 214 | +
|
| 215 | + :host([closing]) [part='overlay'] { |
| 216 | + animation: 200ms overlay-closing-animation; |
| 217 | + } |
| 218 | +
|
| 219 | + @keyframes closing-animation { |
| 220 | + to { |
| 221 | + opacity: 1; |
| 222 | + } |
| 223 | + } |
| 224 | +
|
| 225 | + @keyframes overlay-closing-animation { |
| 226 | + to { |
| 227 | + opacity: 0; |
| 228 | + } |
| 229 | + } |
| 230 | + `; |
| 231 | + overlay.shadowRoot.appendChild(style); |
| 232 | + |
| 233 | + await sendKeys({ down: 'ArrowDown' }); |
| 234 | + const item = getFirstItem(comboBox); |
| 235 | + comboBox.close(); |
| 236 | + await sendMouseToElement({ type: 'click', element: item }); |
| 237 | + |
| 238 | + expect(comboBox.selectedItems).to.deep.equal([]); |
| 239 | + |
| 240 | + await oneEvent(overlay, 'vaadin-overlay-closed'); |
| 241 | + |
| 242 | + expect(comboBox.selectedItems).to.deep.equal([]); |
| 243 | + }); |
206 | 244 | }); |
207 | 245 |
|
208 | 246 | describe('dataProvider', () => { |
|
0 commit comments