@abhivarde/svelte-drawer 1.0.2 → 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,19 +189,17 @@
189
189
  }
190
190
  }
191
191
 
192
- let contentInnerRef = $state<HTMLElement | null>(null);
193
- let measuredHeight = $state<number | null>(null);
194
-
195
192
  $effect(() => {
196
- if (!autoHeight || !contentInnerRef) return;
197
-
198
- const ro = new ResizeObserver((entries) => {
199
- const h = entries[0]?.contentRect.height;
200
- if (h) measuredHeight = h;
201
- });
202
-
203
- ro.observe(contentInnerRef);
204
- 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
+ }
205
203
  });
206
204
 
207
205
  onMount(() => {
@@ -216,9 +214,8 @@
216
214
  <div
217
215
  bind:this={contentElement}
218
216
  class={className}
219
- style="transform: {getTransform()}; z-index: 50; touch-action: none;{autoHeight &&
220
- measuredHeight
221
- ? ` height: ${measuredHeight}px; transition: height 0.25s cubic-bezier(0.4,0,0.2,1);`
217
+ style="transform: {getTransform()}; z-index: 50; touch-action: none;{autoHeight
218
+ ? ' height: auto;'
222
219
  : ''}"
223
220
  tabindex="-1"
224
221
  role="dialog"
@@ -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.2",
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",