fix: fix dialogs within dialogs not opening (#1154)

* fix: fix dialogs within dialogs not opening

fixes #1153

* remove console logs
This commit is contained in:
Nolan Lawson 2019-04-14 19:47:30 -07:00 committed by GitHub
parent ddd95aad27
commit 0649eee366
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 8 deletions

View File

@ -43,7 +43,8 @@
},
data: () => ({
positiveText: void 0,
negativeText: void 0
negativeText: void 0,
className: ''
}),
methods: {
show,

View File

@ -217,13 +217,17 @@
if (otherId !== id) {
return
}
window.addEventListener('popstate', this.onPopState)
this.set({ statePushed: true })
window.history.pushState({ modal: id }, null, location.href)
document.body.classList.toggle('modal-open', true)
this._a11yDialog.show()
requestAnimationFrame(() => {
this.set({ fadedIn: true })
// This setTimeout is dumb, but it fixes issues with modals opening other modals
// due to the popstate/pushstate dance.
setTimeout(() => {
requestAnimationFrame(() => {
window.addEventListener('popstate', this.onPopState)
this.set({ statePushed: true })
window.history.pushState({ modal: id }, null, location.href)
document.body.classList.toggle('modal-open', true)
this._a11yDialog.show()
this.set({ fadedIn: true })
})
})
},
onPopState (event) {

View File

@ -0,0 +1,32 @@
import {
getNthDialogOptionsOption,
getNthStatus, getNthStatusOptionsButton,
modalDialog, sleep, visibleModalDialog
} from '../utils'
import { loginAsFoobar } from '../roles'
fixture`032-mute-dialog.js`
.page`http://localhost:4002`
test('Can open the mute dialog twice', async t => {
await loginAsFoobar(t)
await t
.expect(getNthStatus(1).exists).ok({ timeout: 30000 })
.hover(getNthStatus(1))
.click(getNthStatusOptionsButton(1))
.click(getNthDialogOptionsOption(3))
.expect(visibleModalDialog.innerText).contains('Mute notifications')
await sleep(500)
await t
.pressKey('esc')
.expect(modalDialog.exists).notOk()
await sleep(500)
await t
.click(getNthStatusOptionsButton(1))
.click(getNthDialogOptionsOption(3))
.expect(visibleModalDialog.innerText).contains('Mute notifications')
await sleep(500)
await t
.pressKey('esc')
.expect(modalDialog.exists).notOk()
})