Skip to content

Commit

Permalink
chore: fix qa issues
Browse files Browse the repository at this point in the history
  • Loading branch information
edleeks87 committed Jul 18, 2022
1 parent 04fc2ac commit 6b1dfc8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Meta, Story, Canvas } from "@storybook/addon-docs";
import React from "react";
import { action } from "@storybook/addon-actions";

import specialCharacters from "../../__internal__/utils/argTypes/specialCharacters";
Expand All @@ -13,15 +13,15 @@ import {
} from "./split-button.config";
import SplitButton from "./split-button.component";

<Meta
title="Split Button/Test"
parameters={{
export default {
title: "Split Button/Test",
parameters: {
info: { disable: true },
chromatic: {
disable: true,
},
}}
argTypes={{
},
argTypes: {
iconType: {
options: ["", ...ICONS],
control: {
Expand Down Expand Up @@ -54,9 +54,10 @@ import SplitButton from "./split-button.component";
},
textSpecialCharacters: specialCharacters,
subtextSpecialCharacters: specialCharacters,
}}
/>
},
};

/* eslint-disable react/prop-types */
export const SplitButtonStory = ({
buttonType,
dataElement,
Expand All @@ -68,6 +69,7 @@ export const SplitButtonStory = ({
iconType,
iconPosition,
...args
/* eslint-enable */
}) => {
return (
<Box height={400} mt={100} ml={100}>
Expand Down Expand Up @@ -96,28 +98,20 @@ export const SplitButtonStory = ({
);
};

# Split Button

### Default

<Canvas>
<Story
name="default"
args={{
iconType: "",
iconPosition: "before",
buttonType: "secondary",
dataElement: "data-element",
dataRole: "",
disabled: false,
size: "medium",
align: "left",
text: "Example Split Button",
textSpecialCharacters: undefined,
subtext: "",
subtextSpecialCharacters: undefined,
}}
>
{SplitButtonStory.bind({})}
</Story>
</Canvas>
SplitButtonStory.story = {
name: "default",
args: {
iconType: "",
iconPosition: "before",
buttonType: "secondary",
dataElement: "data-element",
dataRole: "",
disabled: false,
size: "medium",
align: "left",
text: "Example Split Button",
textSpecialCharacters: undefined,
subtext: "",
subtextSpecialCharacters: undefined,
},
};
5 changes: 2 additions & 3 deletions src/components/split-button/split-button.component.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, {
useContext,
useEffect,
useCallback,
useMemo,
useRef,
Expand Down Expand Up @@ -61,7 +60,6 @@ const SplitButton = ({
const buttonContainer = useRef();
const [showAdditionalButtons, setShowAdditionalButtons] = useState(false);
const [minWidth, setMinWidth] = useState(0);
const listening = useRef(false);

const hideButtons = useCallback(() => {
if (toggleButton.current === document.activeElement) return;
Expand Down Expand Up @@ -167,7 +165,8 @@ const SplitButton = ({
if (
Events.isEnterKey(ev) ||
Events.isSpaceKey(ev) ||
Events.isDownKey(ev)
Events.isDownKey(ev) ||
Events.isUpKey(ev)
) {
ev.preventDefault();

Expand Down
1 change: 1 addition & 0 deletions src/components/split-button/split-button.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ describe("SplitButton", () => {
["Enter", "Enter"],
["Space", " "],
["ArrowDown", "ArrowDown"],
["ArrowUp", "ArrowUp"],
])(
"then the first additional button should be focused when %s key is pressed",
(name, key) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/split-button/split-button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ context("Tests for Split Button component", () => {
});
});

describe.each(["Enter", "Space", "downarrow"])(
describe.each(["Enter", "Space", "downarrow", "uparrow"])(
"pressing %s key on the main button",
(key) => {
it("opens SplitButton list and focuses first button", () => {
Expand Down

0 comments on commit 6b1dfc8

Please sign in to comment.