@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 (!autoHeight || !contentInnerRef) return;
196
-
197
- const ro = new ResizeObserver((entries) => {
198
- const entry = entries[0];
199
- if (!entry) return;
200
- const totalHeight = entry.contentRect.height;
201
- const viewportH = window.innerHeight;
202
- const pct = Math.max(0, ((viewportH - totalHeight) / viewportH) * 100);
203
- drawer.drawerPosition.set(pct, { duration: 200 });
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
- <div bind:this={contentInnerRef}>
231
- {@render children()}
232
- </div>
227
+ {@render children()}
233
228
  </div>
234
229
  {/if}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abhivarde/svelte-drawer",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A drawer component for Svelte 5, inspired by Vaul",
5
5
  "author": "Abhi Varde",
6
6
  "license": "MIT",