Skip to content

Commit f0d0195

Browse files
committed
Improve accessibility of intercept option UI
1 parent fc3be1b commit f0d0195

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/components/common/close-button.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import { styled, Theme } from "../../styles";
22
import { Icon } from "../../icons";
3-
import { filterProps, clickOnEnter } from '../component-utils';
3+
import { clickOnEnter } from '../component-utils';
44

55
interface CloseButtonProps {
66
onClose: () => void;
7-
inverted?: boolean;
87
top?: string;
98
right?: string;
109

1110
theme?: Theme;
1211
}
1312

14-
export const CloseButton = styled(
15-
filterProps(Icon, 'inverted')
16-
).attrs((props: CloseButtonProps) => ({
13+
export const CloseButton = styled(Icon).attrs((props: CloseButtonProps) => ({
1714
icon: ['fas', 'times'],
1815
size: '2x',
1916

@@ -25,12 +22,15 @@ export const CloseButton = styled(
2522
z-index: 1;
2623
cursor: pointer;
2724
28-
color: ${(p: CloseButtonProps) => p.inverted ?
29-
p.theme!.mainBackground : p.theme!.mainColor
30-
};
25+
color: ${p => p.theme!.mainColor};
3126
32-
top: ${p => p.top || '10px'};
33-
right: ${p => p.right || '15px'};
27+
&:focus-visible {
28+
outline: none;
29+
color: ${p => p.theme!.popColor};
30+
}
31+
32+
top: ${(p: CloseButtonProps) => p.top || '10px'};
33+
right: ${(p: CloseButtonProps) => p.right || '15px'};
3434
3535
&:hover {
3636
opacity: 0.6;

src/components/intercept/intercept-option.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ export class InterceptOption extends React.Component<InterceptOptionProps> {
231231
? 4
232232
: 3;
233233

234+
const isExpandable = !!ConfigComponent && !isDisabled;
235+
234236
return <InterceptOptionCard
235237
ref={this.cardRef}
236238

@@ -239,6 +241,12 @@ export class InterceptOption extends React.Component<InterceptOptionProps> {
239241
uiConfig={uiConfig}
240242
gridWidth={gridWidth}
241243

244+
role={!this.expanded ? 'button' : 'section'}
245+
aria-expanded={isExpandable
246+
? this.expanded
247+
: undefined
248+
}
249+
242250
disabled={isDisabled}
243251
onKeyDown={clickOnEnter}
244252
onClick={this.expanded ? undefined : this.onClick}
@@ -260,7 +268,10 @@ export class InterceptOption extends React.Component<InterceptOptionProps> {
260268

261269
{ ConfigComponent && expanded
262270
? <>
263-
<CloseButton onClose={this.onClose} />
271+
<CloseButton
272+
title="Close this interceptor"
273+
onClose={this.onClose}
274+
/>
264275
<ConfigComponent
265276
interceptor={interceptor}
266277
activateInterceptor={activateInterceptor}

0 commit comments

Comments
 (0)