Skip to content

Commit

Permalink
Merge pull request #1325 from dxc-technology/gomezivann-fix-1324
Browse files Browse the repository at this point in the history
Replace `"Space"` key by `" "`
  • Loading branch information
aidamag authored Oct 6, 2022
2 parents 1b3d457 + 46eef37 commit 8f4e799
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion lib/src/checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const DxcCheckbox = ({
const handleKeyboard = (event) => {
switch (event.key) {
case " ":
case "Space":
event.preventDefault();
handleCheckboxChange();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/dropdown/Dropdown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ describe("Dropdown component tests", () => {
const { getByRole } = render(<DxcDropdown options={options} label="dropdown-test" />);
const dropdown = getByRole("button");

fireEvent.keyDown(dropdown, { key: "Space", code: "Space", keyCode: 32, charCode: 32 });
fireEvent.keyDown(dropdown, { key: " ", code: "Space", keyCode: 32, charCode: 32 });
const menu = getByRole("menu");
expect(menu).toBeTruthy();
expect(document.activeElement === menu).toBeTruthy();
Expand Down
4 changes: 2 additions & 2 deletions lib/src/dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const DxcDropdown = ({
setVisualFocusIndex(options.length - 1);
handleOnOpenMenu();
break;
case "Space":
case " ":
case "Down":
case "ArrowDown":
case "Enter":
Expand Down Expand Up @@ -112,7 +112,7 @@ const DxcDropdown = ({
event.preventDefault();
setNextIndexFocus();
break;
case "Space":
case " ":
case "Enter":
event.preventDefault();
handleMenuItemOnClick(options[visualFocusIndex].value);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/dropdown/DropdownMenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ const DropdownMenuItemContainer = styled.li<{ visuallyFocused: boolean }>`
cursor: pointer;
${(props) => props.visuallyFocused && `outline: ${props.theme.focusColor} solid 2px; outline-offset: -2px;`}
:hover {
&:hover {
background-color: ${(props) => props.theme.hoverOptionBackgroundColor};
}
:active {
&:active {
background-color: ${(props) => props.theme.activeOptionBackgroundColor};
}
`;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/tabs-nav/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const DxcTab = forwardRef(

const handleOnKeyDown = (event: React.KeyboardEvent<HTMLAnchorElement>) => {
switch (event.key) {
case " ":
case "Enter":
case "Space":
tabRef?.current?.click();
event.preventDefault();
break;
Expand Down

0 comments on commit 8f4e799

Please sign in to comment.