Skip to content

Commit c75880c

Browse files
committed
refactor: create a div to teleport modals to
This commit created a container `div` outside of Vue app to store teleported modal components. It has to be outside of the Vue app, else it won't work because it has not been mounted yet. See more -> vuejs/core#2015
1 parent afd29ce commit c75880c

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
</head>
1313
<body>
1414
<div id="app"></div>
15+
<div id="modal-container"></div>
1516
<script type="module" src="/src/main.js"></script>
1617
</body>
1718
</html>

src/components/ModalConfirmation.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const modalTitle = computed(() => pomodoro.isBreak
2626
</script>
2727

2828
<template>
29-
<Teleport to="body">
29+
<Teleport to="#modal-container">
3030
<Transition
3131
:duration="250"
3232
name="fly-in"

src/components/SettingsForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function onAfterLeave () {
8787
</script>
8888

8989
<template>
90-
<Teleport to="body">
90+
<Teleport to="#modal-container">
9191
<Transition
9292
:duration="250"
9393
name="fly-in"

0 commit comments

Comments
 (0)