Skip to content

Commit e453c9d

Browse files
committed
fix(ui-top-nav-bar,ui-buttons): display a focus ring in TopNavBar if a button has a Popover open
When a menu is active, it should be indicated as the “active” element for a11y reasons Fixes part of INSTUI-4323
1 parent 0362d9f commit e453c9d

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

packages/ui-buttons/src/BaseButton/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ class BaseButton extends Component<BaseButtonProps> {
251251
tabIndex,
252252
styles,
253253
makeStyles,
254+
withFocusOutline,
254255
...props
255256
} = this.props
256257

@@ -307,6 +308,7 @@ class BaseButton extends Component<BaseButtonProps> {
307308
focusRingBorderRadius={String(
308309
(styles?.content as { borderRadius?: string | number })?.borderRadius
309310
)}
311+
withFocusOutline={withFocusOutline}
310312
>
311313
<span css={styles?.content}>{this.renderChildren()}</span>
312314
</View>

packages/ui-buttons/src/BaseButton/props.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,16 @@ type BaseButtonOwnProps = {
152152

153153
/**
154154
* Specifies the tabindex of the `Button`.
155-
*
156155
*/
157156
tabIndex?: number
157+
158+
/**
159+
* Manually control if the `Button` should display a focus outline.
160+
*
161+
* When left `undefined` (which is the default) the focus outline will display
162+
* if this component is focusable and receives focus.
163+
*/
164+
withFocusOutline?: boolean
158165
}
159166

160167
type BaseButtonStyleProps = {
@@ -209,7 +216,8 @@ const propTypes: PropValidators<PropKeys> = {
209216
onClick: PropTypes.func,
210217
onKeyDown: PropTypes.func,
211218
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
212-
tabIndex: PropTypes.number
219+
tabIndex: PropTypes.number,
220+
withFocusOutline: PropTypes.bool
213221
}
214222

215223
const allowedProps: AllowedPropKeys = [

packages/ui-top-nav-bar/src/TopNavBar/TopNavBarItem/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,8 @@ class TopNavBarItem extends Component<TopNavBarItemProps, TopNavBarItemState> {
431431
themeOverride: this.buttonThemeOverride,
432432
elementRef: (e) => {
433433
this.handleItemRef(e as HTMLButtonElement | HTMLLinkElement)
434-
}
434+
},
435+
withFocusOutline: this.hasOpenPopover
435436
}
436437
}
437438

packages/ui-view/src/View/props.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ type ViewOwnProps = {
135135
*/
136136
insetBlockEnd?: string
137137
/**
138-
* Manually control if the `View` should display a focus outline.<br/>
138+
* Manually control if the `View` should display a focus outline.
139+
*
139140
* When left `undefined` (which is the default) the focus outline will display
140141
* automatically if the `View` is focusable and receives focus.
141142
*/

0 commit comments

Comments
 (0)