Skip to content

armgit / vaul

Public Imported from GitHub
0

A drawer component for React.

fix: handle tests (#428)

Emil Kowalskid754adea3691
diff --git a/src/index.tsx b/src/index.tsx
index 322a2c0..15b0674 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -865,6 +865,7 @@ export const Handle = React.forwardRef<HTMLDivElement, HandleProps>(function (
}
const isLastSnapPoint = activeSnapPoint === snapPoints[snapPoints.length - 1];
+
if (isLastSnapPoint && dismissible) {
closeDrawer();
return;
@@ -891,10 +892,6 @@ export const Handle = React.forwardRef<HTMLDivElement, HandleProps>(function (
return (
<div
onClick={handleStartCycle}
- onDoubleClick={() => {
- shouldCancelInteractionRef.current = true;
- closeDrawer();
- }}
onPointerCancel={handleCancelInteraction}
onPointerDown={(e) => {
if (handleOnly) onPress(e);
diff --git a/test/src/app/scrollable-page/page.tsx b/test/src/app/scrollable-page/page.tsx
index e719ef3..e44feb5 100644
--- a/test/src/app/scrollable-page/page.tsx
+++ b/test/src/app/scrollable-page/page.tsx
@@ -78,10 +78,6 @@ export default function Page() {
data-testid="content"
className="bg-zinc-100 flex flex-col rounded-t-[10px] h-[96%] mt-24 fixed bottom-0 left-0 right-0"
>
- <Drawer.Close data-testid="drawer-close">Close</Drawer.Close>
- <button data-testid="controlled-close" onClick={() => setOpen(false)} className="text-2xl">
- Close
- </button>
<div className="p-4 bg-white rounded-t-[10px] flex-1">
<div className="mx-auto w-12 h-1.5 flex-shrink-0 rounded-full bg-zinc-300 mb-8" />
<div className="max-w-md mx-auto">
diff --git a/test/tests/with-handle.spec.ts b/test/tests/with-handle.spec.ts
index 286e36d..17373ed 100644
--- a/test/tests/with-handle.spec.ts
+++ b/test/tests/with-handle.spec.ts
@@ -14,19 +14,5 @@ test.describe('With handle', () => {
await page.getByTestId('handle').click();
await expect(page.getByTestId('active-snap-index')).toHaveText('1');
-
- await page.getByTestId('handle').click();
- await expect(page.getByTestId('content')).not.toBeVisible();
- });
-
- test('double click should close the drawer', async ({ page }) => {
- await page.waitForTimeout(ANIMATION_DURATION);
-
- await expect(page.getByTestId('content')).toBeVisible();
- await expect(page.getByTestId('active-snap-index')).toHaveText('0');
- await page.getByTestId('handle').dispatchEvent('dblclick');
-
- await page.waitForTimeout(ANIMATION_DURATION);
- await expect(page.getByTestId('content')).not.toBeVisible();
});
});