Skip to content

Commit

Permalink
feat: backdrop element to improve autohide on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Feb 1, 2022
1 parent 25e14b2 commit 803dcca
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
11 changes: 7 additions & 4 deletions packages/docs/src/.vuepress/components/DropdownMobileDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default {

<div v-if="isMobile">
<button
class="bg-gray-300 rounded px-4 py-2"
class="bg-gray-300 rounded px-4 py-2 w-full"
@click="hide()"
>
Cancel
Expand All @@ -75,17 +75,20 @@ body.no-scroll {
left: 0;
width: 100%;
height: 100%;
background: rgba(0 0 0 / 90%);
pointer-events: none;
display: flex;
align-items: flex-end;
padding: 12px;
}
.v-popper__popper--no-positioning .v-popper__backdrop {
display: block;
background: rgba(0 0 0 / 90%);
}
.v-popper__popper--no-positioning .v-popper__wrapper {
width: 100%;
pointer-events: auto;
transition: transform .15s ease-out;
padding: 12px;
}
.v-popper__popper--no-positioning.v-popper__popper--hidden .v-popper__wrapper {
Expand Down
15 changes: 14 additions & 1 deletion packages/floating-vue/src/components/PopperContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
:data-popper-placement="result ? result.placement : undefined"
@keyup.esc="autoHide && $emit('hide')"
>
<div
class="v-popper__backdrop"
@click="autoHide && $emit('hide')"
/>
<div
class="v-popper__wrapper"
:style="result ? {
Expand Down Expand Up @@ -113,6 +117,7 @@ export default {
visibility: hidden;
opacity: 0;
transition: opacity .15s, visibility .15s;
pointer-events: none;
}
.v-popper__popper.v-popper__popper--shown {
Expand All @@ -126,6 +131,15 @@ export default {
transition: none !important;
}
.v-popper__backdrop {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: none;
}
.v-popper__inner {
position: relative;
box-sizing: border-box;
Expand Down Expand Up @@ -250,5 +264,4 @@ export default {
.v-popper__popper[data-popper-placement^="left"] .v-popper__arrow-inner {
left: -2px;
}
</style>

0 comments on commit 803dcca

Please sign in to comment.