-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve the dialog and drawer scrollbar experience, fix internal…
… click failure problems and warnings (#4391) * fix: improve the dialog and drawer scrollbar experience, fix internal click failure problems and warnings * chore: remove test code
- Loading branch information
Showing
20 changed files
with
186 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { getScrollbarWidth } from '@vben-core/shared/utils'; | ||
|
||
import { | ||
useScrollLock as _useScrollLock, | ||
tryOnBeforeMount, | ||
tryOnBeforeUnmount, | ||
} from '@vueuse/core'; | ||
|
||
export const SCROLL_FIXED_CLASS = `_scroll__fixed_`; | ||
|
||
export function useScrollLock() { | ||
const isLocked = _useScrollLock(document.body); | ||
const scrollbarWidth = getScrollbarWidth(); | ||
|
||
tryOnBeforeMount(() => { | ||
document.body.style.paddingRight = `${scrollbarWidth}px`; | ||
|
||
const layoutFixedNodes = document.querySelectorAll<HTMLElement>( | ||
`.${SCROLL_FIXED_CLASS}`, | ||
); | ||
const nodes = [...layoutFixedNodes]; | ||
if (nodes.length > 0) { | ||
nodes.forEach((node) => { | ||
node.dataset.transition = node.style.transition; | ||
node.style.transition = 'none'; | ||
node.style.paddingRight = `${scrollbarWidth}px`; | ||
}); | ||
} | ||
isLocked.value = true; | ||
}); | ||
|
||
tryOnBeforeUnmount(() => { | ||
isLocked.value = false; | ||
const layoutFixedNodes = document.querySelectorAll<HTMLElement>( | ||
`.${SCROLL_FIXED_CLASS}`, | ||
); | ||
const nodes = [...layoutFixedNodes]; | ||
if (nodes.length > 0) { | ||
nodes.forEach((node) => { | ||
node.style.paddingRight = ''; | ||
requestAnimationFrame(() => { | ||
node.style.transition = node.dataset.transition || ''; | ||
}); | ||
}); | ||
} | ||
document.body.style.paddingRight = ''; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ export default defineBuildConfig({ | |
{ | ||
builder: 'mkdist', | ||
input: './src', | ||
|
||
pattern: ['**/*'], | ||
}, | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/@core/ui-kit/shadcn-ui/src/components/ui/dialog/DialogOverlay.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script setup lang="ts"> | ||
import { useScrollLock } from '@vben-core/composables'; | ||
useScrollLock(); | ||
</script> | ||
<template> | ||
<div | ||
class="data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 bg-overlay fixed inset-0 z-[1000]" | ||
data-dismissable-modal="true" | ||
></div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/@core/ui-kit/shadcn-ui/src/components/ui/sheet/SheetOverlay.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script setup lang="ts"> | ||
import { useScrollLock } from '@vben-core/composables'; | ||
useScrollLock(); | ||
</script> | ||
<template> | ||
<div | ||
class="bg-overlay data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[1000]" | ||
data-dismissable-modal="true" | ||
></div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.