|
1 | 1 | import { expect } from '@vaadin/chai-plugins'; |
2 | | -import { resetMouse, sendKeys, sendMouse } from '@vaadin/test-runner-commands'; |
| 2 | +import { resetMouse, sendKeys, sendMouse, sendMouseToElement } from '@vaadin/test-runner-commands'; |
3 | 3 | import { fixtureSync, keyboardEventFor, nextRender } from '@vaadin/testing-helpers'; |
4 | 4 | import sinon from 'sinon'; |
5 | 5 | import '../src/vaadin-multi-select-combo-box.js'; |
@@ -155,6 +155,32 @@ describe('selecting items', () => { |
155 | 155 | expect(comboBox.selectedItems).to.deep.equal([]); |
156 | 156 | }); |
157 | 157 |
|
| 158 | + it('should reset the item focused state when closing on outside click', async () => { |
| 159 | + await sendKeys({ press: 'ArrowDown' }); |
| 160 | + await sendKeys({ press: 'ArrowDown' }); |
| 161 | + await sendMouseToElement({ type: 'click', element: document.body }); |
| 162 | + await resetMouse(); |
| 163 | + |
| 164 | + await sendKeys({ press: 'ArrowDown' }); |
| 165 | + const item = getFirstItem(comboBox); |
| 166 | + expect(item.hasAttribute('focused')).to.be.false; |
| 167 | + }); |
| 168 | + |
| 169 | + it('should reset the item focused state when closing on blur', async () => { |
| 170 | + await sendKeys({ press: 'ArrowDown' }); |
| 171 | + await sendKeys({ press: 'ArrowDown' }); |
| 172 | + |
| 173 | + // Blur the combo-box |
| 174 | + await sendKeys({ press: 'Shift+Tab' }); |
| 175 | + |
| 176 | + // Focus and re-open |
| 177 | + await sendKeys({ press: 'Tab' }); |
| 178 | + |
| 179 | + await sendKeys({ press: 'ArrowDown' }); |
| 180 | + const item = getFirstItem(comboBox); |
| 181 | + expect(item.hasAttribute('focused')).to.be.false; |
| 182 | + }); |
| 183 | + |
158 | 184 | it('should not select an item on blur when it is focused', async () => { |
159 | 185 | await sendKeys({ down: 'ArrowDown' }); |
160 | 186 | await sendKeys({ down: 'ArrowDown' }); |
|
0 commit comments