Skip to content

Commit 88da1e3

Browse files
committed
feat: Add Tippy tooltip to MultiSelectCustomization Option component
1 parent cd0fbd0 commit 88da1e3

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

src/Common/MultiSelectCustomization.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,23 @@
1616

1717
import React from 'react'
1818
import Select, { components } from 'react-select'
19+
import Tippy from '@tippyjs/react'
1920
import { ReactComponent as ClearIcon } from '../Assets/Icon/ic-appstatus-cancelled.svg'
2021
import { ReactComponent as ICErrorCross } from '@Icons/ic-error-cross.svg'
2122
import { ReactComponent as Check } from '../Assets/Icon/ic-check.svg'
2223
import { ReactComponent as RedWarning } from '../Assets/Icon/ic-error-medium.svg'
2324
import { Checkbox } from './Checkbox'
2425
import { CHECKBOX_VALUE } from './Types'
26+
import { ConditionalWrap } from './Helper'
2527

2628
export const Option = (props) => {
27-
const { selectOption, data } = props
29+
const { selectOption, data, showTippy, tippyPlacement } = props
2830

2931
const handleChange = (e) => {
3032
selectOption(data)
3133
}
3234

33-
return (
35+
const renderOption = () => (
3436
<div
3537
className="flex left pl-12 cursor dc__gap-8"
3638
style={{ background: props.isFocused ? 'var(--N100)' : 'transparent' }}
@@ -44,6 +46,26 @@ export const Option = (props) => {
4446
<components.Option {...props} />
4547
</div>
4648
)
49+
50+
const renderTippy = (children) => {
51+
const placement = tippyPlacement === 'left' || tippyPlacement === 'right' ? tippyPlacement : 'auto'
52+
return (
53+
<Tippy
54+
content={data.label}
55+
className="default-tt dc__mxw-200 dc__word-break"
56+
placement={placement}
57+
arrow={false}
58+
>
59+
{children}
60+
</Tippy>
61+
)
62+
}
63+
64+
return (
65+
<ConditionalWrap condition={showTippy} wrap={renderTippy}>
66+
{renderOption()}
67+
</ConditionalWrap>
68+
)
4769
}
4870

4971
export const SingleSelectOption = (props) => {

src/Shared/Components/Plugin/PluginTagSelect.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { useCallback, useEffect, useMemo, useState } from 'react'
22
import ReactSelect, { MenuListProps, ValueContainerProps } from 'react-select'
3-
import { Option, OptionType } from '../../../Common'
3+
import { OptionType } from '../../../Common'
44
import { LoadingIndicator, MenuListWithApplyButton, MultiSelectValueContainer } from '../ReactSelect'
55
import { GenericSectionErrorState } from '../GenericSectionErrorState'
66
import { PluginTagSelectProps } from './types'
7-
import { pluginTagSelectStyles } from './utils'
7+
import { PluginTagOption, pluginTagSelectStyles } from './utils'
88

99
const PluginTagSelect = ({
1010
availableTags,
@@ -78,7 +78,7 @@ const PluginTagSelect = ({
7878
LoadingIndicator,
7979
NoOptionsMessage: renderNoOptionsMessage,
8080
MenuList: renderMenuList,
81-
Option,
81+
Option: PluginTagOption,
8282
ValueContainer: renderValueContainer,
8383
}}
8484
menuIsOpen={isMenuOpen}

src/Shared/Components/Plugin/utils.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { OptionProps } from 'react-select'
2+
import { OptionType } from '@Common/Types'
3+
import { Option } from '@Common/MultiSelectCustomization'
14
import { ParentPluginDTO, PluginCreationType, PluginDataStoreType } from './types'
25
import { commonSelectStyles } from '../ReactSelect'
36
import { stringComparatorBySortOrder } from '../../Helpers'
@@ -100,6 +103,10 @@ export const pluginTagSelectStyles = {
100103
}),
101104
}
102105

106+
export const PluginTagOption = (props: OptionProps<OptionType, true>) => (
107+
<Option {...props} showTippy placement="left" />
108+
)
109+
103110
/**
104111
* @description This method takes the initial plugin data store and updates the keys with the target parent plugin store and plugin version store
105112
*/

0 commit comments

Comments
 (0)