Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure multi-action and split button children container is not hidden by parent overflow #7135

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
29 changes: 28 additions & 1 deletion src/components/accordion/accordion-test.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { action } from "@storybook/addon-actions";
import { Accordion, AccordionGroup } from ".";
import Textbox from "../textbox";
import Box from "../box";
import MultiActionButton from "../multi-action-button";
import SplitButton from "../split-button";
import Button from "../button/button.component";

export default {
title: "Accordion/Test",
includeStories: ["Default", "Grouped"],
includeStories: ["Default", "Grouped", "AccordionWithMultiAction"],
parameters: {
info: { disable: true },
chromatic: {
Expand Down Expand Up @@ -112,3 +115,27 @@ export const Grouped = ({ ...args }) => (
);

Grouped.storyName = "grouped";

export const AccordionWithMultiAction = () => {
return (
<Accordion title="Accordion">
<MultiActionButton text="Multi Action Button">
<Button>Button 1</Button>
<Button>Button 2</Button>
<Button>Button 3</Button>
<Button>Button 4</Button>
<Button>Button 5</Button>
</MultiActionButton>
<SplitButton text="Split Button">
<Button>Button 1</Button>
<Button>Button 2</Button>
<Button>Button 3</Button>
<Button>Button 4</Button>
<Button>Button 5</Button>
</SplitButton>
</Accordion>
);
};

AccordionWithMultiAction.storyName =
"Accordion with MultiAction and Split Button";
18 changes: 18 additions & 0 deletions src/components/accordion/accordion.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@
AccordionGroupDefault,
AccordionGroupValidation,
AccordionWithDefinitionList,
AccordionWithSplit,
} from "./components.test-pw";

import { additionalButton as splitAdditionalButtons } from "../../../playwright/components/split-button";

const testData = [CHARACTERS.DIACRITICS, CHARACTERS.SPECIALCHARACTERS];

test.describe("when focused", () => {
// TODO: Skipped due to flaky focus behaviour. To review in FE-6428
test.skip("should have the expected styling when the focusRedesignOptOut is false", async ({

Check warning on line 50 in src/components/accordion/accordion.pw.tsx

View workflow job for this annotation

GitHub Actions / Lint

Test skipped. If unresolved, raise a JIRA ticket or GitHub issue, then reference it in a code comment above
mount,
page,
}) => {
Expand All @@ -63,7 +66,7 @@
});

// TODO: Skipped due to flaky focus behaviour. To review in FE-6428
test.skip("should have the expected styling when the focusRedesignOptOut is true", async ({

Check warning on line 69 in src/components/accordion/accordion.pw.tsx

View workflow job for this annotation

GitHub Actions / Lint

Test skipped. If unresolved, raise a JIRA ticket or GitHub issue, then reference it in a code comment above
mount,
page,
}) => {
Expand Down Expand Up @@ -455,6 +458,21 @@
await expect(accordionTitleContainer(page)).toContainText("subtle");
await expect(accordionTitleContainer(page)).not.toContainText("subtitle");
});

test("should not hide the children container of SplitButton when it opens", async ({
mount,
page,
}) => {
await mount(<AccordionWithSplit />);

await getDataElementByValue(page, "dropdown").click();

await expect(splitAdditionalButtons(page, 0)).toBeVisible();
await expect(splitAdditionalButtons(page, 1)).toBeVisible();
await expect(splitAdditionalButtons(page, 2)).toBeVisible();
await expect(splitAdditionalButtons(page, 3)).toBeVisible();
await expect(splitAdditionalButtons(page, 4)).toBeVisible();
});
});

test.describe("should render Accordion Grouped component", () => {
Expand Down
15 changes: 15 additions & 0 deletions src/components/accordion/components.test-pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Button from "../button/button.component";
import { Checkbox } from "../checkbox";
import { Dl, Dt, Dd } from "../definition-list";
import Link from "../link/link.component";
import SplitButton from "../split-button";

const errorVal = "error";
const warningVal = "warning";
Expand Down Expand Up @@ -550,3 +551,17 @@ export const AccordionWithDefinitionList = () => {
</Accordion>
);
};

export const AccordionWithSplit = () => {
return (
<Accordion expanded title="Accordion">
<SplitButton text="Split Button">
<Button>Button 1</Button>
<Button>Button 2</Button>
<Button>Button 3</Button>
<Button>Button 4</Button>
<Button>Button 5</Button>
</SplitButton>
</Accordion>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const MultiActionButton = ({
: /* istanbul ignore next */ "bottom-end"
}
reference={buttonNode}
popoverStrategy="fixed"
middleware={[
offset(6),
flip({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ test.describe("Prop tests", () => {

(
[
["left", 0],
["right", -46],
["left", 198],
["right", 152],
] as [MultiActionButtonProps["position"], number][]
).forEach(([position, value]) => {
test(`should render with menu position to the ${position}`, async ({
Expand All @@ -120,7 +120,7 @@ test.describe("Prop tests", () => {
const actionButton = getComponent(page, "multi-action-button");
await actionButton.click();
const listContainer = getDataElementByValue(page, "additional-buttons");
await expect(listContainer).toHaveCSS("position", "absolute");
await expect(listContainer).toHaveCSS("position", "fixed");
await assertCssValueIsApproximately(listContainer, "top", 46);
await assertCssValueIsApproximately(listContainer, "left", value);
});
Expand Down
1 change: 1 addition & 0 deletions src/components/split-button/split-button.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export const SplitButton = ({
? /* istanbul ignore next */ "bottom-start"
: "bottom-end"
}
popoverStrategy="fixed"
reference={buttonNode}
middleware={[
offset(6),
Expand Down
6 changes: 3 additions & 3 deletions src/components/split-button/split-button.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ test.describe("Prop tests", () => {

(
[
["left", 0],
["right", 42],
["left", 198],
["right", 242],
] as [SplitButtonProps["position"], number][]
).forEach(([position, value]) => {
test(`should render with menu position to the ${position}`, async ({
Expand All @@ -276,7 +276,7 @@ test.describe("Prop tests", () => {

await getDataElementByValue(page, "dropdown").click();
const listContainer = additionalButtonsContainer(page);
await expect(listContainer).toHaveCSS("position", "absolute");
await expect(listContainer).toHaveCSS("position", "fixed");
await assertCssValueIsApproximately(listContainer, "top", 46);
await assertCssValueIsApproximately(listContainer, "left", value);
});
Expand Down
Loading