Skip to content

Commit a82e3a5

Browse files
committed
fix: focus trap with fallback;
fix: low z-index value;
1 parent 89d4269 commit a82e3a5

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"url": "https://github.com/megaarmos/vue-spring-bottom-sheet/issues"
3333
},
3434
"private": false,
35-
"version": "1.2.0",
35+
"version": "1.2.1",
3636
"type": "module",
3737
"exports": {
3838
".": {

src/BottomSheet.vue

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ const { height: sheetHeaderHeight } = useElementBounding(sheetHeader)
5757
const { height: sheetFooterHeight } = useElementBounding(sheetFooter)
5858
const { height: sheetContentHeight } = useElementBounding(sheetContent)
5959
60-
const { activate, deactivate } = useFocusTrap([sheet, backdrop], { immediate: false })
60+
// Focus trap
61+
let focusTrap = useFocusTrap([sheet, backdrop], {
62+
immediate: false,
63+
fallbackFocus: () => sheet.value || document.body,
64+
})
6165
6266
// Computed values
6367
const minHeightComputed = computed(() =>
@@ -123,7 +127,7 @@ const open = () => {
123127
setTimeout(() => {
124128
if (motionValues.value.y!.get() - 0 < 0.1) {
125129
emit('opened')
126-
activate()
130+
focusTrap.activate()
127131
}
128132
}, props.duration)
129133
}
@@ -143,7 +147,7 @@ const close = () => {
143147
isWindowRootScrollLocked.value = false
144148
145149
if (props.blocking) {
146-
deactivate()
150+
focusTrap.deactivate()
147151
}
148152
149153
window.removeEventListener('keydown', handleEscapeKey)
@@ -452,14 +456,23 @@ defineExpose({ open, close, snapToPoint })
452456
</template>
453457

454458
<style scoped>
459+
[data-vsbs-container] {
460+
position: fixed;
461+
inset: 0px;
462+
overflow: hidden;
463+
pointer-events: none;
464+
z-index: 9999;
465+
visibility: visible;
466+
}
467+
455468
[data-vsbs-backdrop] {
456469
background-color: var(--vsbs-backdrop-bg, rgba(0, 0, 0, 0.5));
457470
inset: 0;
458471
pointer-events: auto;
459472
position: fixed;
460473
user-select: none;
461474
will-change: opacity;
462-
z-index: 100;
475+
z-index: 1;
463476
}
464477
465478
[data-vsbs-shadow='true'] {
@@ -485,7 +498,7 @@ defineExpose({ open, close, snapToPoint })
485498
visibility: hidden;
486499
width: 100%;
487500
will-change: height;
488-
z-index: 100;
501+
z-index: 2;
489502
}
490503
491504
[data-vsbs-sheet-show='true'] {
@@ -497,7 +510,7 @@ defineExpose({ open, close, snapToPoint })
497510
flex-shrink: 0;
498511
padding: 20px var(--vsbs-padding-x, 16px) 8px;
499512
user-select: none;
500-
z-index: 1;
513+
z-index: 3;
501514
}
502515
503516
[data-vsbs-header]:before {

0 commit comments

Comments
 (0)