Skip to content

Commit

Permalink
Fix scroll in MenuItem in navigation section (#5023)
Browse files Browse the repository at this point in the history
* Fix scroll in MenuItem in navigation section

* Add changeset

---------

Co-authored-by: Paweł Chyła <[email protected]>
  • Loading branch information
soniaklimas and poulch committed Aug 9, 2024
1 parent 8e91df3 commit 69160a0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/wise-rice-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Make MenuItems' container scrollable in navigation section
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ describe("AutocompleteSelectMenu", () => {
testIds: ["1", "2", "3", "4"],
};

const { container } = render(<AutocompleteSelectMenu {...defaultProps} />);

it("renders without crashing", () => {
// Arrange & Act
const { container } = render(<AutocompleteSelectMenu {...defaultProps} />);

// Assert
expect(container).toBeInTheDocument();
Expand Down Expand Up @@ -97,7 +98,7 @@ describe("AutocompleteSelectMenu", () => {

it("shows inner list when option is selected", async () => {
// Arrange
const { getByPlaceholderText, getByText } = render(
const { getByPlaceholderText, getByText, getByTestId } = render(
<IntlProvider locale="en">
<AutocompleteSelectMenu {...defaultProps} />
</IntlProvider>,
Expand All @@ -109,11 +110,18 @@ describe("AutocompleteSelectMenu", () => {

const option = getByText("Option 1");

const scrollableContainer = getByTestId("menu-link-options");

scrollableContainer.scrollTop = option.offsetTop;

fireEvent.click(option);

// Assert
await waitFor(() => {
expect(getByText("Option 1 Child")).toBeInTheDocument();
const childOption = getByText("Option 1 Child");

scrollableContainer.scrollTop = childOption.offsetTop;
expect(childOption).toBeInTheDocument();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const useStyles = makeStyles(
position: "absolute",
right: 0,
zIndex: 2,
overflow: "auto",
maxHeight: "300px",
},
root: {},
}),
Expand Down

0 comments on commit 69160a0

Please sign in to comment.