-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: always close select on outside click when in modeless dialog (#8727
- Loading branch information
1 parent
4ede722
commit faeab89
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { expect } from '@vaadin/chai-plugins'; | ||
import { resetMouse, sendMouseToElement } from '@vaadin/test-runner-commands'; | ||
import { fixtureSync, nextRender, oneEvent } from '@vaadin/testing-helpers'; | ||
import './not-animated-styles.js'; | ||
import '@vaadin/dialog'; | ||
import '@vaadin/select'; | ||
|
||
describe('select in dialog', () => { | ||
let dialog, select; | ||
|
||
beforeEach(async () => { | ||
dialog = fixtureSync('<vaadin-dialog modeless></vaadin-dialog>'); | ||
dialog.headerTitle = 'Title'; | ||
dialog.renderer = (root) => { | ||
if (!root.firstChild) { | ||
root.innerHTML = '<vaadin-select></vaadin-select>'; | ||
} | ||
}; | ||
dialog.opened = true; | ||
await oneEvent(dialog.$.overlay, 'vaadin-overlay-open'); | ||
select = dialog.$.overlay.querySelector('vaadin-select'); | ||
select.items = [ | ||
{ label: 'Option 1', value: 'value-1' }, | ||
{ label: 'Option 2', value: 'value-2' }, | ||
]; | ||
}); | ||
|
||
afterEach(async () => { | ||
await resetMouse(); | ||
}); | ||
|
||
it('should close the select on dialog header title click', async () => { | ||
select.opened = true; | ||
await nextRender(); | ||
|
||
// Use title slot part instead of the actual slotted title HTML element, | ||
// since `getBoundingClientRect()` for the latter returns 0 coordinates. | ||
const title = dialog.$.overlay.shadowRoot.querySelector('[part="title"]'); | ||
|
||
await sendMouseToElement({ type: 'click', element: title }); | ||
|
||
expect(select.opened).to.be.false; | ||
}); | ||
}); |