@@ -91,23 +91,12 @@ type ToggleButtonProps = {
91
91
expanded : boolean ;
92
92
} ;
93
93
94
- const ToggleButton = ( props : ToggleButtonProps ) => {
95
- const classNames = getClassName ( 'bpk-info-banner__expand-icon' ) ;
96
-
97
- return (
98
- < button
99
- type = "button"
100
- className = { getClassName ( 'bpk-info-banner__toggle-button' ) }
101
- aria-label = { props . label }
102
- aria-expanded = { props . expanded }
103
- title = { props . label }
104
- >
105
- < div className = { classNames } >
106
- { props . expanded ? < CollapseIcon /> : < ExpandIcon /> }
107
- </ div >
108
- </ button >
109
- ) ;
110
- } ;
94
+ const ToggleButton = ( props : ToggleButtonProps ) => (
95
+ < div className = { getClassName ( 'bpk-info-banner__toggle-button' ) } >
96
+ { props . expanded ? < CollapseIcon /> : < ExpandIcon /> }
97
+ < span className = "visually-hidden" > { props . label } </ span >
98
+ </ div >
99
+ ) ;
111
100
112
101
type Props = CommonProps & {
113
102
action ?: ExpandableBannerAction ;
@@ -159,7 +148,7 @@ const BpkInfoBannerInner = ({
159
148
const dismissable = configuration === CONFIGURATION . DISMISSABLE ;
160
149
const showChildren = isExpandable && expanded ;
161
150
162
- const sectionClassNames = getClassName (
151
+ const classNames = getClassName (
163
152
'bpk-info-banner' ,
164
153
`bpk-info-banner--${ type } ` ,
165
154
`bpk-info-banner--style-${ style } ` ,
@@ -175,22 +164,21 @@ const BpkInfoBannerInner = ({
175
164
? getClassName ( 'bpk-info-banner__children-container--with-action' )
176
165
: getClassName ( 'bpk-info-banner__children-container--no-action' )
177
166
178
- /* eslint-disable
179
- jsx-a11y/no-static-element-interactions,
180
- jsx-a11y/click-events-have-key-events,
181
- */
182
- // Disabling 'click-events-have-key-events and interactive-supports-focus' because header element is not focusable.
183
- // ToggleButton is focusable and works for this.
167
+ const BannerHeader = isExpandable ? 'button' : 'div' ;
168
+
184
169
return (
185
170
< AnimateAndFade
186
171
animateOnEnter = { animateOnEnter }
187
172
animateOnLeave = { dismissable || animateOnLeave }
188
173
show = { show }
189
174
{ ...rest }
190
175
>
191
- < section className = { sectionClassNames } role = "presentation" >
192
- < div
193
- role = { isExpandable ? 'button' : undefined }
176
+ < div className = { classNames } >
177
+ < BannerHeader
178
+ aria-expanded = { isExpandable ? expanded : undefined }
179
+ type = { isExpandable ? 'button' : undefined }
180
+ // BannerHeader is just <button> or <div>, so className should be allowed.
181
+ // eslint-disable-next-line @skyscanner/rules/forbid-component-props
194
182
className = { headerClassNames }
195
183
onClick = { onBannerExpandToggle }
196
184
>
@@ -214,7 +202,7 @@ const BpkInfoBannerInner = ({
214
202
/>
215
203
</ span >
216
204
) }
217
- </ div >
205
+ </ BannerHeader >
218
206
< BpkAnimateHeight
219
207
duration = { parseInt ( durationSm , 10 ) }
220
208
height = { showChildren ? 'auto' : 0 }
@@ -230,10 +218,9 @@ const BpkInfoBannerInner = ({
230
218
</ BpkLink >
231
219
) }
232
220
</ BpkAnimateHeight >
233
- </ section >
221
+ </ div >
234
222
</ AnimateAndFade >
235
223
) ;
236
- /* eslint-enable */
237
224
} ;
238
225
239
226
export default BpkInfoBannerInner ;
0 commit comments