@@ -10,7 +10,10 @@ import AccordionContext from 'react-bootstrap/AccordionContext';
1010import './AccordionToggle.scss' ;
1111import { faChevronUp } from '@fortawesome/pro-solid-svg-icons' ;
1212
13+ import { isEventKeyActive } from './utils' ;
14+
1315type AccordionToggleProps = {
16+ borderBottom ?: boolean ;
1417 /**
1518 Set Chevron icon to open/close quarter turn from lateral
1619 */
@@ -30,6 +33,7 @@ type AccordionToggleProps = {
3033 */
3134 disabled ?: boolean ;
3235 eventKey : string ;
36+ flush ?: boolean ;
3337 helperText ?: string ;
3438 leadingIcon ?: object ;
3539 title ?: string ;
@@ -38,13 +42,15 @@ type AccordionToggleProps = {
3842} ;
3943
4044function AccordionToggle ( {
45+ borderBottom,
4146 children,
4247 chevronLateral,
4348 chevronLeft,
4449 chevronRight,
4550 collapsedText,
4651 disabled,
4752 eventKey,
53+ flush,
4854 helperText,
4955 leadingIcon,
5056 title,
@@ -54,10 +60,12 @@ function AccordionToggle({
5460} : AccordionToggleProps ) {
5561 const { activeEventKey } = React . useContext ( AccordionContext ) ;
5662
63+ const eventKeyIsActive = isEventKeyActive ( eventKey , activeEventKey ) ;
64+
5765 const [ isCollapsed , setIsCollapsed ] = useState ( true ) ;
5866
5967 const decoratedOnClick = useAccordionButton ( eventKey , ( ) => {
60- if ( eventKey !== activeEventKey ) {
68+ if ( ! eventKeyIsActive ) {
6169 setIsCollapsed ( false ) ;
6270 }
6371 setIsCollapsed ( ( prev ) => ! prev ) ;
@@ -68,14 +76,14 @@ function AccordionToggle({
6876 } ;
6977
7078 useEffect ( ( ) => {
71- if ( activeEventKey && eventKey !== activeEventKey ) {
79+ if ( ! eventKeyIsActive ) {
7280 handleCloseInactiveToggle ( ) ;
7381 }
7482
75- if ( activeEventKey && eventKey === activeEventKey ) {
83+ if ( eventKeyIsActive ) {
7684 setIsCollapsed ( ( ( prev ) => ! prev ) ) ;
7785 }
78- } , [ activeEventKey , eventKey ] ) ;
86+ } , [ eventKeyIsActive ] ) ;
7987
8088 return (
8189 < button
@@ -92,7 +100,7 @@ function AccordionToggle({
92100 type = "button"
93101 onClick = { decoratedOnClick }
94102 >
95- < div className = " AccordionToggle__container" >
103+ < div className = { classNames ( ' AccordionToggle__container' , { flush } , { borderBottom } ) } >
96104 < div className = "AccordionToggle__container--content" >
97105 { chevronLeft && (
98106 < span className = "AccordionToggle__chevron-left" >
0 commit comments