Skip to content

Commit 240897e

Browse files
feat(Modal): add scrollable prop (#5306)
1 parent 6964deb commit 240897e

File tree

22 files changed

+840
-279
lines changed

22 files changed

+840
-279
lines changed

docs/app/components/content/examples/drawer/DrawerDismissibleExample.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ const open = ref(false)
33
</script>
44

55
<template>
6-
<UDrawer v-model:open="open" :dismissible="false" :handle="false" :ui="{ header: 'flex items-center justify-between' }">
6+
<UDrawer v-model:open="open" :dismissible="false" :modal="false" :handle="false">
77
<UButton label="Open" color="neutral" variant="subtle" trailing-icon="i-lucide-chevron-up" />
88

9-
<template #header>
10-
<h2 class="text-highlighted font-semibold">
11-
Drawer non-dismissible
12-
</h2>
9+
<template #body>
10+
<div class="flex items-center justify-between gap-4 mb-4">
11+
<h2 class="text-highlighted font-semibold">
12+
Drawer non-dismissible
13+
</h2>
1314

14-
<UButton color="neutral" variant="ghost" icon="i-lucide-x" @click="open = false" />
15-
</template>
15+
<UButton color="neutral" variant="ghost" icon="i-lucide-x" @click="open = false" />
16+
</div>
1617

17-
<template #body>
18-
<Placeholder class="h-48" />
18+
<Placeholder class="size-full min-h-48" />
1919
</template>
2020
</UDrawer>
2121
</template>

docs/app/components/content/examples/drawer/DrawerModalExample.vue

Lines changed: 0 additions & 28 deletions
This file was deleted.

docs/app/components/content/examples/popover/PopoverDismissibleExample.vue

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
<script setup lang="ts">
2-
const open = ref(false)
3-
</script>
4-
51
<template>
6-
<UPopover v-model:open="open" :dismissible="false" :ui="{ content: 'p-4' }">
2+
<UPopover :dismissible="false" :ui="{ content: 'p-4' }">
73
<UButton label="Open" color="neutral" variant="subtle" />
84

9-
<template #content>
5+
<template #content="{ close }">
106
<div class="flex items-center gap-4 mb-4">
117
<h2 class="text-highlighted font-semibold">
128
Popover non-dismissible
139
</h2>
1410

15-
<UButton color="neutral" variant="ghost" icon="i-lucide-x" @click="open = false" />
11+
<UButton color="neutral" variant="ghost" icon="i-lucide-x" @click="close" />
1612
</div>
1713

1814
<Placeholder class="size-full min-h-48" />

docs/content/docs/2.components/context-menu.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,43 @@ slots:
218218
:div{class="flex items-center justify-center rounded-md border border-dashed border-accented text-sm aspect-video w-72"}[Right click here]
219219
::
220220

221+
### Modal
222+
223+
Use the `modal` prop to control whether the ContextMenu blocks interaction with outside content. Defaults to `true`.
224+
225+
::component-code
226+
---
227+
prettier: true
228+
ignore:
229+
- items
230+
- ui.content
231+
external:
232+
- items
233+
externalTypes:
234+
- ContextMenuItem[]
235+
props:
236+
modal: false
237+
items:
238+
- label: System
239+
icon: i-lucide-monitor
240+
- label: Light
241+
icon: i-lucide-sun
242+
- label: Dark
243+
icon: i-lucide-moon
244+
ui:
245+
content: 'w-48'
246+
slots:
247+
default: |
248+
249+
<div class="flex items-center justify-center rounded-md border border-dashed border-accented text-sm aspect-video w-72">
250+
Right click here
251+
</div>
252+
---
253+
254+
:div{class="flex items-center justify-center rounded-md border border-dashed border-accented text-sm aspect-video w-72"}[Right click here]
255+
::
256+
257+
221258
### Disabled
222259

223260
Use the `disabled` prop to disable the ContextMenu.

docs/content/docs/2.components/drawer.md

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,54 @@ slots:
216216
:placeholder{class="h-48 m-4"}
217217
::
218218

219+
### Modal
220+
221+
Use the `modal` prop to control whether the Drawer blocks interaction with outside content. Defaults to `true`.
222+
223+
::note
224+
When `modal` is set to `false`, the overlay is automatically disabled and outside content becomes interactive.
225+
::
226+
227+
::component-code
228+
---
229+
prettier: true
230+
props:
231+
modal: false
232+
slots:
233+
default: |
234+
235+
<UButton label="Open" color="neutral" variant="subtle" trailing-icon="i-lucide-chevron-up" />
236+
237+
content: |
238+
239+
<Placeholder class="h-48 m-4" />
240+
---
241+
242+
:u-button{label="Open" color="neutral" variant="subtle" trailing-icon="i-lucide-chevron-up"}
243+
244+
#content
245+
:placeholder{class="h-48 m-4"}
246+
::
247+
248+
### Dismissible
249+
250+
Use the `dismissible` prop to control whether the Drawer is dismissible when clicking outside of it or pressing escape. Defaults to `true`.
251+
252+
::note
253+
A `close:prevent` event will be emitted when the user tries to close it.
254+
::
255+
256+
::tip
257+
You can combine `modal: false` with `dismissible: false` to make the Drawer's background interactive without closing it.
258+
::
259+
260+
::component-example
261+
---
262+
prettier: true
263+
name: 'drawer-dismissible-example'
264+
---
265+
::
266+
219267
### Scale Background
220268

221269
Use the `should-scale-background` prop to scale the background when the Drawer is open, creating a visual depth effect. You can set the `set-background-color-on-scale` prop to `false` to prevent changing the background color.
@@ -291,32 +339,6 @@ In this example, leveraging [`defineShortcuts`](/docs/composables/define-shortcu
291339
This allows you to move the trigger outside of the Drawer or remove it entirely.
292340
::
293341

294-
### Disable dismissal
295-
296-
Set the `dismissible` prop to `false` to prevent the Drawer from being closed when clicking outside of it or pressing escape. A `close:prevent` event will be emitted when the user tries to close it.
297-
298-
::component-example
299-
---
300-
prettier: true
301-
name: 'drawer-dismissible-example'
302-
---
303-
::
304-
305-
::note
306-
In this example, the `header` slot is used to add a close button which is not done by default.
307-
::
308-
309-
### With interactive background
310-
311-
Set the `overlay` and `modal` props to `false` alongside the `dismissible` prop to make the Drawer's background interactive without closing the Drawer.
312-
313-
::component-example
314-
---
315-
prettier: true
316-
name: 'drawer-modal-example'
317-
---
318-
::
319-
320342
### Responsive drawer
321343

322344
You can render a [Modal](/docs/components/modal) component on desktop and a Drawer on mobile for example.

docs/content/docs/2.components/dropdown-menu.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,40 @@ The `size` prop will not be proxied to the Button, you need to set it yourself.
307307
When using the same size, the DropdownMenu items will be perfectly aligned with the Button.
308308
::
309309

310+
### Modal
311+
312+
Use the `modal` prop to control whether the DropdownMenu blocks interaction with outside content. Defaults to `true`.
313+
314+
::component-code
315+
---
316+
prettier: true
317+
ignore:
318+
- items
319+
- ui.content
320+
external:
321+
- items
322+
externalTypes:
323+
- DropdownMenuItem[]
324+
props:
325+
modal: false
326+
items:
327+
- label: Profile
328+
icon: i-lucide-user
329+
- label: Billing
330+
icon: i-lucide-credit-card
331+
- label: Settings
332+
icon: i-lucide-cog
333+
ui:
334+
content: 'w-48'
335+
slots:
336+
default: |
337+
338+
<UButton label="Open" icon="i-lucide-menu" color="neutral" variant="outline" />
339+
---
340+
341+
:u-button{label="Open" icon="i-lucide-menu" color="neutral" variant="outline"}
342+
::
343+
310344
### Disabled
311345

312346
Use the `disabled` prop to disable the DropdownMenu.

0 commit comments

Comments
 (0)