diff --git a/e2e/picklist.spec.ts b/e2e/picklist.spec.ts index 046f7fd..3d4c485 100644 --- a/e2e/picklist.spec.ts +++ b/e2e/picklist.spec.ts @@ -206,6 +206,31 @@ test.describe('Active pick list', () => { await expect(page.getByText(/Qty:\s*1\s+unit/i)).toBeVisible(); }); + test('closes mobile controls with the close button and backdrop', async ({ page }) => { + await page.setViewportSize({ width: 390, height: 844 }); + + await navigateToNewPickList(page); + await addProductToPickList(page, additionalProduct); + + const productRow = page + .getByText(additionalProduct, { exact: true }) + .locator('xpath=ancestor::div[contains(@class, "MuiStack-root")]') + .first(); + const controlsDialog = page.getByRole('dialog', { name: additionalProduct }); + + await productRow.click(); + await expect(controlsDialog).toBeVisible(); + + await page.getByRole('button', { name: 'Close controls' }).click(); + await expect(controlsDialog).toHaveCount(0); + + await productRow.click(); + await expect(controlsDialog).toBeVisible(); + + await page.locator('.MuiBackdrop-root').click({ position: { x: 10, y: 10 } }); + await expect(controlsDialog).toHaveCount(0); + }); + test('toggles picked visibility and disables the filter when all items are picked', async ({ page }) => { await navigateToNewPickList(page); await addProductToPickList(page, secondaryProduct); diff --git a/src/components/PickItemRow.tsx b/src/components/PickItemRow.tsx index cf409ff..3944147 100644 --- a/src/components/PickItemRow.tsx +++ b/src/components/PickItemRow.tsx @@ -60,6 +60,10 @@ export const PickItemRow = ({ } }; + const handleCloseControls = () => { + setIsControlsOpen(false); + }; + const handleRowKeyDown = (event: React.KeyboardEvent) => { if (!isNarrowScreen) return; @@ -182,7 +186,7 @@ export const PickItemRow = ({ {isNarrowScreen && ( setIsControlsOpen(false)} + onClose={handleCloseControls} fullWidth maxWidth="xs" aria-labelledby="item-controls-title" @@ -196,10 +200,7 @@ export const PickItemRow = ({ { - stopPropagation(event); - setIsControlsOpen(false); - }} + onClick={handleCloseControls} >