File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import CIcon from '@coreui/icons-react'
1111import { useLocation } from 'react-router-dom'
1212
1313import { Context } from './CSidebar'
14+ export const DropdownContext = React . createContext ( { } )
1415
1516export const iconProps = ( icon ) => {
1617 if ( typeof icon === 'object' ) {
@@ -100,13 +101,20 @@ const CSidebarNavDropdown = props => {
100101 { ...attributes }
101102 ref = { ref }
102103 >
103- < a className = "c-sidebar-nav-dropdown-toggle" onClick = { toggle } >
104+ < a
105+ className = "c-sidebar-nav-dropdown-toggle"
106+ tabIndex = "0"
107+ onClick = { toggle }
108+ aria-label = "menu dropdown"
109+ >
104110 { icon && ( isValidElement ( icon ) ? icon : < CIcon { ...iconProps ( icon ) } /> ) }
105111 { fontIcon && < i className = { iconClasses } /> }
106112 { name }
107113 </ a >
108114 < ul className = "c-sidebar-nav-dropdown-items" >
109- { children }
115+ < DropdownContext . Provider value = { { isOpen } } >
116+ { children }
117+ </ DropdownContext . Provider >
110118 </ ul >
111119 </ li >
112120 )
Original file line number Diff line number Diff line change 1- import React , { isValidElement } from 'react'
1+ import React , { isValidElement , useContext } from 'react'
22import PropTypes from 'prop-types'
33import classNames from 'classnames'
44import { CLink , CBadge } from '../index'
55import CIcon from '@coreui/icons-react'
66import { iconProps } from './CSidebarNavDropdown'
77
8+ import { DropdownContext } from './CSidebarNavDropdown'
9+
810//component - CoreUI / CSidebarNavItem
911const CSidebarNavItem = props => {
1012
@@ -23,7 +25,7 @@ const CSidebarNavItem = props => {
2325 ...rest
2426 } = props
2527
26- //render
28+ const { isOpen } = useContext ( DropdownContext )
2729 const classes = classNames (
2830 'c-sidebar-nav-item' ,
2931 className
@@ -43,6 +45,7 @@ const CSidebarNavItem = props => {
4345 className = { linkClasses }
4446 { ...routerLinkProps }
4547 { ...rest }
48+ tabIndex = { isOpen === false ? - 1 : 0 }
4649 >
4750 { icon && ( isValidElement ( icon ) ? icon : < CIcon { ...iconProps ( icon ) } /> ) }
4851 { fontIcon && < i className = { `c-sidebar-nav-icon ${ fontIcon } ` } /> }
You can’t perform that action at this time.
0 commit comments