Skip to content

Commit eeec2c8

Browse files
committed
fix(#2929): add keyboard handlers to non-interactive elements
1 parent 93ca8ff commit eeec2c8

File tree

8 files changed

+45
-4
lines changed

8 files changed

+45
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ changes.
1515
- Add metadata url and hash to drep details [Issue 2911](https://github.com/IntersectMBO/govtool/issues/2911)
1616
- Add CC votes percentages, not voted and Ratification threshold
1717
- Add support for submitting all 7 governance action types [Issue 2258](https://github.com/IntersectMBO/govtool/issues/2258)
18+
- Add click handlers to non-interactive elements [Issue 2929](https://github.com/IntersectMBO/govtool/issues/2929)
1819

1920
### Fixed
2021

govtool/frontend/src/components/atoms/CopyButton.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ export const CopyButton = ({ isChecked, text, variant }: Props) => {
4141
}}
4242
src={iconSrc}
4343
style={{ cursor: "pointer" }}
44+
onKeyDown={(e) => {
45+
if (e.ctrlKey && e.key === "c") {
46+
navigator.clipboard.writeText(text);
47+
addSuccessAlert(t("alerts.copiedToClipboard"));
48+
e.stopPropagation();
49+
}
50+
}}
4451
/>
4552
);
4653
};

govtool/frontend/src/components/atoms/StakeRadio.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,20 @@ export const StakeRadio: FC<StakeRadioProps> = ({ ...props }) => {
5757
>
5858
{stakeKey}
5959
</Typography>
60-
<IconButton color="primary">
60+
<IconButton color="primary" tabIndex={0}>
6161
<img
6262
alt="copy"
6363
onClick={(e) => {
6464
navigator.clipboard.writeText(stakeKey);
6565
e.stopPropagation();
6666
}}
6767
src={isChecked ? ICONS.copyWhiteIcon : ICONS.copyIcon}
68+
onKeyDown={(e) => {
69+
if (e.ctrlKey && e.key === "c") {
70+
navigator.clipboard.writeText(stakeKey);
71+
e.stopPropagation();
72+
}
73+
}}
6874
/>
6975
</IconButton>
7076
</Box>

govtool/frontend/src/components/molecules/CopyableInfo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const CopyableInfo = ({
3333
<Typography color={gray.c300} fontSize={12} fontWeight={500}>
3434
{label}
3535
</Typography>
36-
<Box sx={{ display: "flex", justifyContent: "space-between" }}>
36+
<Box sx={{ display: "flex", justifyContent: "space-between" }} tabIndex={0}>
3737
<Typography
3838
textOverflow="ellipsis"
3939
overflow="hidden"

govtool/frontend/src/components/molecules/DRepInfoCard.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ export const DRepInfoCard = () => {
1818

1919
return (
2020
<Card border elevation={0} sx={{ p: 1.5 }}>
21-
<Box sx={{ display: "flex", justifyContent: "space-between" }}>
21+
<Box
22+
sx={{ display: "flex", justifyContent: "space-between" }}
23+
tabIndex={0}
24+
>
2225
<Typography color={gray.c300} fontSize={12} fontWeight={500}>
2326
{t("myDRepId")}
2427
</Typography>

govtool/frontend/src/components/molecules/GovernanceActionCardElement.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,16 @@ export const GovernanceActionCardElement = ({
198198
},
199199
});
200200
}}
201+
onKeyDown={(e) => {
202+
if (e.key === "Enter") {
203+
openModal({
204+
type: "externalLink",
205+
state: {
206+
externalLink: text.toString(),
207+
},
208+
});
209+
}
210+
}}
201211
/>
202212
</Box>
203213
)}

govtool/frontend/src/components/molecules/GovernanceActionDetailsCardLinks.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ export const GovernanceActionDetailsCardLinks = ({
9090
},
9191
});
9292
}}
93+
onKeyDown={(e) => {
94+
if (e.key === "Enter") {
95+
openModal({
96+
type: "externalLink",
97+
state: {
98+
externalLink: uri,
99+
},
100+
});
101+
}
102+
}}
93103
/>
94104
</Box>
95105
)}

govtool/frontend/src/components/organisms/TopNav.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import { DrawerMobile } from "./DrawerMobile";
1414
const POSITION_TO_BLUR = 50;
1515

1616
export const TopNav = ({ isConnectButton = true }) => {
17-
const { isProposalDiscussionForumEnabled, isGovernanceOutcomesPillarEnabled } = useFeatureFlag();
17+
const {
18+
isProposalDiscussionForumEnabled,
19+
isGovernanceOutcomesPillarEnabled,
20+
} = useFeatureFlag();
1821
const containerRef = useRef<HTMLDivElement>(null);
1922
const [shouldBlur, setShouldBlur] = useState<boolean>(false);
2023
const { openModal } = useModal();
@@ -189,6 +192,7 @@ export const TopNav = ({ isConnectButton = true }) => {
189192
alt="drawer-icon"
190193
src={ICONS.drawerIcon}
191194
onClick={openDrawer}
195+
onKeyDown={(e) => e.key === "Enter" && openDrawer()}
192196
data-testid="open-drawer-button"
193197
/>
194198
)}

0 commit comments

Comments
 (0)