Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4709f15
commit c8462df
Showing
6 changed files
with
118 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<script setup lang="ts"> | ||
import { ModalsContainer } from '~/index' | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<div v-for="i in 1000" :key="i"> | ||
id: {{ i }} | ||
</div> | ||
<slot /> | ||
|
||
<ModalsContainer /> | ||
</div> | ||
</template> |
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,24 @@ | ||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
const emit = defineEmits<{ | ||
(e: 'submit', payload: { | ||
account: string | ||
password: string | ||
}): void | ||
}>() | ||
const account = ref('') | ||
const password = ref('') | ||
</script> | ||
|
||
<template> | ||
<form @submit.prevent="() => emit('submit', { account, password })"> | ||
<label>Account:<input v-model="account" class="form-account" type="text"></label> | ||
<label>Password:<input v-model="password" class="form-password" type="password"></label> | ||
|
||
<button class="form-submit" type="submit"> | ||
Submit | ||
</button> | ||
</form> | ||
</template> |
60 changes: 60 additions & 0 deletions
60
packages/vue-final-modal/cypress/components/focusTrap.spec.ts
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,60 @@ | ||
import App from './App.vue' | ||
import Form from './Form.vue' | ||
import { VueFinalModal, createVfm, useModal } from '~/index' | ||
|
||
describe('Test focusTrap', () => { | ||
it('Props: focusTrap', () => { | ||
const vfm = createVfm() | ||
|
||
const firstModal = useModal({ | ||
context: vfm, | ||
component: VueFinalModal, | ||
attrs: { contentClass: 'first-modal-content' }, | ||
slots: { | ||
default: Form, | ||
}, | ||
}) | ||
|
||
const secondModal = useModal({ | ||
context: vfm, | ||
component: VueFinalModal, | ||
attrs: { contentClass: 'second-modal-content' }, | ||
slots: { | ||
default: '<p>Hello world!</p>', | ||
}, | ||
}) | ||
|
||
cy.mount(App, { | ||
global: { | ||
plugins: [vfm], | ||
stubs: { transition: false }, | ||
}, | ||
}) | ||
.then(async () => { | ||
await firstModal.open() | ||
cy.focused().as('firstModalFocus') | ||
cy.get('@firstModalFocus').should('have.class', 'first-modal-content') | ||
}) | ||
.then(async () => { | ||
cy.get('.form-submit').focus() | ||
cy.focused().as('formSubmitFocus') | ||
cy.get('@formSubmitFocus').should('have.class', 'form-submit') | ||
}) | ||
.then(async () => { | ||
await secondModal.open() | ||
cy.focused().as('secondModalFocus') | ||
cy.get('@secondModalFocus').should('have.class', 'second-modal-content') | ||
}) | ||
.then(async () => { | ||
await secondModal.close() | ||
cy.focused().as('formSubmitFocus') | ||
cy.get('@formSubmitFocus').should('have.class', 'form-submit') | ||
}) | ||
.then(async () => { | ||
await firstModal.close() | ||
await firstModal.open() | ||
cy.focused().as('firstModalFocus') | ||
cy.get('@firstModalFocus').should('have.class', 'first-modal-content') | ||
}) | ||
}) | ||
}) |
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
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