Skip to content

Commit

Permalink
Add allowBodyScroll prop
Browse files Browse the repository at this point in the history
  • Loading branch information
gokh4nozturk committed Dec 13, 2023
1 parent 19e759e commit 361e30f
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/components/Modal/RModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,29 @@ export interface ModalProps {
* <Modal style="color: red" />
*/
style?: string
/**
* Control the scroll of the body
* @type boolean
* @default false
* @example
* <Modal :modelValue="true" :allowBodyScroll="true" />
*/
allowBodyScroll?: boolean
}
const props = withDefaults(defineProps<ModalProps>(), {
modelValue: false,
block: false,
title: '',
description: '',
icon: '',
width: '',
height: '',
outsideClick: false,
class: '',
overlayClass: '',
style: '',
allowBodyScroll: false,
})
const emits = defineEmits(['update:modelValue'])
const classes = computed(() => {
Expand All @@ -126,7 +143,7 @@ function handleOutside(event: Event) {
emits('update:modelValue', false)
}
watchEffect(() => {
if (props.modelValue)
if (props.modelValue && !props.allowBodyScroll)
document.body.style.overflow = 'hidden'
else
document.body.style.overflow = 'auto'
Expand Down

0 comments on commit 361e30f

Please sign in to comment.