Skip to content

Commit d4dc889

Browse files
author
Amrit Kashyap Borah
committed
chore: conditional wrap in bulk selection
1 parent 1f18d07 commit d4dc889

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/Shared/Components/BulkSelection/BulkSelection.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import { forwardRef, MouseEvent } from 'react'
1818

1919
import { ReactComponent as ICChevronDown } from '../../../Assets/Icon/ic-chevron-down.svg'
20-
import { Checkbox, noop } from '../../../Common'
20+
import { Checkbox, ConditionalWrap, noop } from '../../../Common'
2121
import { ActionMenu, ActionMenuItemType, ActionMenuProps } from '../ActionMenu'
2222
import { useBulkSelection } from './BulkSelectionProvider'
2323
import { BULK_DROPDOWN_TEST_ID, BulkSelectionOptionsLabels } from './constants'
@@ -73,7 +73,9 @@ const BulkSelection = forwardRef<HTMLLabelElement, BulkSelectionProps>(
7373
})
7474
}
7575

76-
return (
76+
const shouldWrapActionMenu = !selectAllIfNotPaginated || showPagination
77+
78+
const wrapWithActionMenu = (children: React.ReactElement) => (
7779
<ActionMenu
7880
id={BULK_DROPDOWN_TEST_ID}
7981
onClick={onActionMenuClick}
@@ -84,6 +86,12 @@ const BulkSelection = forwardRef<HTMLLabelElement, BulkSelectionProps>(
8486
},
8587
]}
8688
>
89+
{children}
90+
</ActionMenu>
91+
)
92+
93+
return (
94+
<ConditionalWrap wrap={wrapWithActionMenu} condition={shouldWrapActionMenu}>
8795
<div className="flexbox dc__gap-4 dc__align-items-center">
8896
<Checkbox
8997
ref={forwardedRef}
@@ -92,13 +100,13 @@ const BulkSelection = forwardRef<HTMLLabelElement, BulkSelectionProps>(
92100
rootClassName="icon-dim-20 m-0"
93101
value={checkboxValue}
94102
disabled={disabled}
95-
onClick={selectAllIfNotPaginated && !showPagination ? onSinglePageSelectAll : null}
103+
onClick={!shouldWrapActionMenu ? onSinglePageSelectAll : null}
96104
// Ideally should be disabled but was giving issue with cursor
97105
/>
98106

99107
{showChevronDownIcon && <ICChevronDown className="icon-dim-20 fcn-6 dc__no-shrink" />}
100108
</div>
101-
</ActionMenu>
109+
</ConditionalWrap>
102110
)
103111
},
104112
)

0 commit comments

Comments
 (0)