Skip to content

Commit b12981e

Browse files
committed
Update: add a unique modal class to body when modal open
1 parent a0729e7 commit b12981e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/components/Modal.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
</div>
5454
</template>
5555
<script>
56+
import { useId } from 'vue'
5657
import Resizer from './Resizer.vue'
5758
import {
5859
isInput,
@@ -211,6 +212,8 @@ export default {
211212
shiftLeft: 0,
212213
shiftTop: 0,
213214
215+
modalId: useId(),
216+
214217
modal: {
215218
width: 0,
216219
widthType: 'px',
@@ -432,6 +435,10 @@ export default {
432435
this.overlayTransitionState === TransitionState.Leave &&
433436
this.modalTransitionState === TransitionState.Leave
434437
)
438+
},
439+
440+
bodyModalClass() {
441+
return `vm--${this.modalId}`;
435442
}
436443
},
437444
@@ -666,6 +673,8 @@ export default {
666673
document.body.classList.add('vm--block-scroll')
667674
}
668675
676+
document.body.classList.add(this.bodyModalClass)
677+
669678
let cancelEvent = false
670679
671680
const cancel = () => {
@@ -705,6 +714,8 @@ export default {
705714
document.body.classList.remove('vm--block-scroll')
706715
}
707716
717+
document.body.classList.remove(this.bodyModalClass)
718+
708719
let cancelEvent = false
709720
710721
const cancel = () => {

0 commit comments

Comments
 (0)