Skip to content

Commit f6b29f2

Browse files
authored
Merge pull request #2660 from appwrite/fix-modal-overflows
2 parents fc11a90 + 7d10c30 commit f6b29f2

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

src/lib/components/drop.svelte

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<script lang="ts">
66
import { createPopper, type Instance } from '@popperjs/core';
7-
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
7+
import { createEventDispatcher, onDestroy, onMount, hasContext } from 'svelte';
88
99
export let show = false;
1010
export let noArrow = false;
@@ -17,6 +17,10 @@
1717
export let display = 'block';
1818
export let arrowSize = 10;
1919
export let isPopover = false;
20+
export let portal = false;
21+
22+
const inModal = hasContext('dialog-group');
23+
const shouldPortalTooltip = portal || inModal;
2024
2125
const dispatch = createEventDispatcher<{
2226
blur: undefined;
@@ -27,6 +31,22 @@
2731
let arrow: HTMLDivElement;
2832
let instance: Instance;
2933
34+
function portalAction(node: HTMLElement) {
35+
if (!shouldPortalTooltip) return;
36+
37+
const bodyElement = document.body;
38+
const target = inModal ? node.closest('dialog[open]') || bodyElement : bodyElement;
39+
target.appendChild(node);
40+
41+
return {
42+
destroy() {
43+
if (node.parentElement === target) {
44+
target.removeChild(node);
45+
}
46+
}
47+
};
48+
}
49+
3050
onMount(() => {
3151
instance = createPopper(element, tooltip, {
3252
placement,
@@ -116,6 +136,7 @@
116136
</div>
117137

118138
<div
139+
use:portalAction
119140
class="drop-tooltip"
120141
bind:this={tooltip}
121142
class:u-width-full-line={fullWidth}

src/lib/components/dropList.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
export let paddingInline: string = undefined;
1919
export let resetListPadding: boolean = false;
2020
export let gap: string = undefined;
21+
export let portal = false;
2122
let classes: string = '';
2223
export { classes as class };
2324
</script>
@@ -31,6 +32,7 @@
3132
{fullWidth}
3233
{wrapperFullWidth}
3334
{fixed}
35+
{portal}
3436
on:blur>
3537
<slot />
3638
<svelte:fragment slot="list">

src/lib/components/modal.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,5 @@
5757
/* temporary fix to modal width */
5858
:global(dialog section) {
5959
max-width: 100% !important;
60-
overflow: visible !important;
6160
}
6261
</style>

0 commit comments

Comments
 (0)