@abhivarde/svelte-drawer 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -189,22 +189,17 @@
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
let contentInnerRef = $state<HTMLElement | null>(null);
|
|
193
|
-
|
|
194
192
|
$effect(() => {
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
ro.observe(contentInnerRef);
|
|
207
|
-
return () => ro.disconnect();
|
|
193
|
+
if (drawer.open && trapFocus && contentElement) {
|
|
194
|
+
tick().then(() => {
|
|
195
|
+
const focusable = getFocusableElements();
|
|
196
|
+
if (focusable[0]) {
|
|
197
|
+
focusable[0].focus({ preventScroll: true });
|
|
198
|
+
} else {
|
|
199
|
+
contentElement?.focus({ preventScroll: true });
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
208
203
|
});
|
|
209
204
|
|
|
210
205
|
onMount(() => {
|
|
@@ -219,7 +214,9 @@
|
|
|
219
214
|
<div
|
|
220
215
|
bind:this={contentElement}
|
|
221
216
|
class={className}
|
|
222
|
-
style="transform: {getTransform()}; z-index: 50; touch-action: none;
|
|
217
|
+
style="transform: {getTransform()}; z-index: 50; touch-action: none;{autoHeight
|
|
218
|
+
? ' height: auto;'
|
|
219
|
+
: ''}"
|
|
223
220
|
tabindex="-1"
|
|
224
221
|
role="dialog"
|
|
225
222
|
aria-modal="true"
|
|
@@ -227,8 +224,6 @@
|
|
|
227
224
|
ontouchstart={onPointerDown}
|
|
228
225
|
{...restProps}
|
|
229
226
|
>
|
|
230
|
-
|
|
231
|
-
{@render children()}
|
|
232
|
-
</div>
|
|
227
|
+
{@render children()}
|
|
233
228
|
</div>
|
|
234
229
|
{/if}
|