File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed
packages/compass-connections-navigation/src Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ type NavigationBaseItemProps = {
2828 actions : NavigationItemActions ;
2929 onAction : ( action : Actions ) => void ;
3030 } ;
31- onExpand : ( toggle : boolean ) => void ;
31+ toggleExpand : ( ) => void ;
3232} ;
3333
3434const menuStyles = css ( {
@@ -98,7 +98,7 @@ export const NavigationBaseItem: React.FC<NavigationBaseItemProps> = ({
9898 isExpanded,
9999 isFocused,
100100 hasDefaultAction,
101- onExpand ,
101+ toggleExpand ,
102102 children,
103103} ) => {
104104 const [ hoverProps , isHovered ] = useHoverState ( ) ;
@@ -114,11 +114,7 @@ export const NavigationBaseItem: React.FC<NavigationBaseItemProps> = ({
114114 < div className = { cx ( 'item-wrapper' , itemWrapperStyles ) } style = { style } >
115115 { isExpandVisible && (
116116 < ExpandButton
117- onClick = { ( evt ) => {
118- if ( isExpandDisabled ) return ;
119- evt . stopPropagation ( ) ;
120- onExpand ( ! isExpanded ) ;
121- } }
117+ onClick = { toggleExpand }
122118 isExpanded = { isExpanded }
123119 disabled = { isExpandDisabled }
124120 > </ ExpandButton >
Original file line number Diff line number Diff line change @@ -242,6 +242,12 @@ export function NavigationItem({
242242 return actions ;
243243 } , [ item , isDarkMode ] ) ;
244244
245+ const toggleExpand = useCallback ( ( ) => {
246+ if ( item . type !== 'placeholder' ) {
247+ onItemExpand ( item , ! item . isExpanded ) ;
248+ }
249+ } , [ onItemExpand , item ] ) ;
250+
245251 return (
246252 < StyledNavigationItem item = { item } >
247253 { item . type === 'placeholder' ? (
@@ -262,9 +268,7 @@ export function NavigationItem({
262268 isExpandDisabled = {
263269 item . type === 'connection' && item . connectionStatus !== 'connected'
264270 }
265- onExpand = { ( isExpanded : boolean ) => {
266- onItemExpand ( item , isExpanded ) ;
267- } }
271+ toggleExpand = { toggleExpand }
268272 actionProps = { actionProps }
269273 >
270274 { ! ! connectionStaticActions . length && (
You can’t perform that action at this time.
0 commit comments