File tree 4 files changed +23
-12
lines changed
4 files changed +23
-12
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " vaul-vue " : patch
3
+ ---
4
+
5
+ fix body style persist after unmount, clicking overlay not dismissing drawer
Original file line number Diff line number Diff line change @@ -41,10 +41,12 @@ function handlePointerDownOutside(event: Event) {
41
41
if (keyboardIsOpen .value )
42
42
keyboardIsOpen .value = false
43
43
44
- event .preventDefault ()
45
-
46
- if (dismissible .value )
44
+ if (dismissible .value ) {
47
45
emitOpenChange (false )
46
+ }
47
+ else {
48
+ event .preventDefault ()
49
+ }
48
50
}
49
51
50
52
function handlePointerDown(event : PointerEvent ) {
Original file line number Diff line number Diff line change @@ -519,10 +519,6 @@ export function useDrawer(props: UseDrawerProps & DialogEmitHandlers): DrawerRoo
519
519
}
520
520
} )
521
521
522
- onUnmounted ( ( ) => {
523
- restorePositionSetting ( )
524
- } )
525
-
526
522
function onRelease ( event : PointerEvent ) {
527
523
if ( ! isDragging . value || ! drawerRef . value )
528
524
return
Original file line number Diff line number Diff line change @@ -25,6 +25,11 @@ export function usePositionFixed(options: PositionFixedOptions) {
25
25
const scrollPos = ref ( 0 )
26
26
27
27
function setPositionFixed ( ) : void {
28
+ // All browsers on iOS will return true here.
29
+ if ( ! isSafari ( ) )
30
+ return
31
+
32
+ // If previousBodyPosition is already set, don't set it again.
28
33
if ( previousBodyPosition === null && isOpen . value && ! noBodyStyles . value ) {
29
34
previousBodyPosition = {
30
35
position : document . body . style . position ,
@@ -33,13 +38,16 @@ export function usePositionFixed(options: PositionFixedOptions) {
33
38
height : document . body . style . height ,
34
39
}
35
40
41
+ // Update the dom inside an animation frame
36
42
const { scrollX, innerHeight } = window
37
43
38
- document . body . style . position = 'fixed'
39
- document . body . style . top = `-${ scrollPos . value } px`
40
- document . body . style . left = `-${ scrollX } px`
41
- document . body . style . right = '0px'
42
- document . body . style . height = 'auto'
44
+ document . body . style . setProperty ( 'position' , 'fixed' , 'important' )
45
+ Object . assign ( document . body . style , {
46
+ top : `${ - scrollPos . value } px` ,
47
+ left : `${ - scrollX } px` ,
48
+ right : '0px' ,
49
+ height : 'auto' ,
50
+ } )
43
51
44
52
setTimeout ( ( ) => {
45
53
requestAnimationFrame ( ( ) => {
You can’t perform that action at this time.
0 commit comments