Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ export class MenuCategory
}
this.closeOtherCategories.emit(this.categoryId);

this.showDropdown = true;

if (this.dropdownRef.current) {
const ref = dropdownController.getDropdownById(
this.dropdownRef.current.dataset.ixDropdown!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,55 @@ regressionTest(
}
);

regressionTest(
'should allow scrolling in dropdown with many items when no category item is active',
async ({ mount, page }) => {
await mount(`
<ix-application>
<ix-menu>
<ix-menu-category label="Category label">
<ix-menu-item>Item 1</ix-menu-item>
<ix-menu-item>Item 2</ix-menu-item>
<ix-menu-item>Item 3</ix-menu-item>
<ix-menu-item>Item 4</ix-menu-item>
<ix-menu-item>Item 5</ix-menu-item>
<ix-menu-item>Item 6</ix-menu-item>
<ix-menu-item>Item 7</ix-menu-item>
<ix-menu-item>Item 8</ix-menu-item>
<ix-menu-item>Item 9</ix-menu-item>
<ix-menu-item>Item 10</ix-menu-item>
<ix-menu-item>Item 11</ix-menu-item>
<ix-menu-item>Item 12</ix-menu-item>
<ix-menu-item>Item 13</ix-menu-item>
<ix-menu-item>Item 14</ix-menu-item>
<ix-menu-item>Item 15</ix-menu-item>
<ix-menu-item>Item 16</ix-menu-item>
<ix-menu-item>Item 17</ix-menu-item>
<ix-menu-item>Item 18</ix-menu-item>
<ix-menu-item>Item 19</ix-menu-item>
</ix-menu-category>
</ix-menu>
</ix-application>
`);

const menuCategory = page.locator('ix-menu-category');
await menuCategory.hover();

const dropdown = menuCategory.locator('ix-dropdown');
await expect(dropdown).toBeVisible();

const isScrollable = await dropdown.evaluate((el) => {
return el.scrollHeight > el.clientHeight;
});
expect(isScrollable).toBe(true);

const lastItem = menuCategory
.locator('ix-menu-item:not(.category-parent)')
.last();
await expect(lastItem).not.toBeHidden();
Comment on lines +587 to +595

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Exercise the scroll and click path.

scrollHeight > clientHeight only proves that overflow exists. not.toBeHidden() also passes when the final item is outside the visible scrollport. Scroll the final item into view, click it, and assert the dropdown closes. This validates the user interaction fixed by this PR.

Proposed test update
     expect(isScrollable).toBe(true);

     const lastItem = menuCategory
       .locator('ix-menu-item:not(.category-parent)')
       .last();
-    await expect(lastItem).not.toBeHidden();
+    await lastItem.scrollIntoViewIfNeeded();
+    await expect(lastItem).toBeInViewport();
+    await lastItem.click();
+    await expect(dropdown).not.toBeVisible();

As per coding guidelines, update tests for user-facing behavior changes and use core component tests for interaction behavior.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const isScrollable = await dropdown.evaluate((el) => {
return el.scrollHeight > el.clientHeight;
});
expect(isScrollable).toBe(true);
const lastItem = menuCategory
.locator('ix-menu-item:not(.category-parent)')
.last();
await expect(lastItem).not.toBeHidden();
const isScrollable = await dropdown.evaluate((el) => {
return el.scrollHeight > el.clientHeight;
});
expect(isScrollable).toBe(true);
const lastItem = menuCategory
.locator('ix-menu-item:not(.category-parent)')
.last();
await lastItem.scrollIntoViewIfNeeded();
await expect(lastItem).toBeInViewport();
await lastItem.click();
await expect(dropdown).not.toBeVisible();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/components/menu-category/test/menu-category.ct.ts` around
lines 587 - 595, Update the scrollability test around menuCategory to exercise
the interaction path: scroll the final non-parent menu item into the dropdown’s
visible area, click it, and assert that the dropdown closes. Retain the overflow
assertion, but replace the visibility-only check with assertions that validate
the user-facing selection behavior.

Source: Coding guidelines

}
);

regressionTest(
'should move into expanded category items when pressing ArrowDown on category button',
async ({ mount, page }) => {
Expand Down
Loading