Skip to content

Commit 8df1551

Browse files
feat(pill-selector-dropdown): allow setting error tooltip position (#3330)
* feat(pill-selector-dropdown): allow setting error tooltip position * fix: fix default prop type --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent b2c878a commit 8df1551

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎src/components/pill-selector-dropdown/PillSelector.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import RoundPill from './RoundPill';
1111
import Pill from './Pill';
1212
import SuggestedPillsRow from './SuggestedPillsRow';
1313
import type { RoundOption, Option, OptionValue, SuggestedPillsFilter } from './flowTypes';
14+
import type { Position } from '../tooltip';
1415

1516
function stopDefaultEvent(event) {
1617
event.preventDefault();
@@ -22,6 +23,8 @@ type Props = {
2223
className?: string,
2324
disabled?: boolean,
2425
error?: React.Node,
26+
/** Position of error message tooltip */
27+
errorTooltipPosition?: Position,
2528
/** Called on pill render to get a specific class name to use for a particular option. Note: Only has effect when showRoundedPills is true. */
2629
getPillClassName?: (option: Option) => string,
2730
/** Function to retrieve the image URL associated with a pill */
@@ -52,6 +55,7 @@ type DefaultProps = {
5255
allowInvalidPills: boolean,
5356
disabled: boolean,
5457
error: string,
58+
errorTooltipPosition: Position,
5559
inputProps: Object,
5660
placeholder: string,
5761
selectedOptions: List<Object>,
@@ -65,6 +69,7 @@ class PillSelectorBase extends React.Component<Props, State> {
6569
allowInvalidPills: false,
6670
disabled: false,
6771
error: '',
72+
errorTooltipPosition: 'bottom-left',
6873
inputProps: {},
6974
placeholder: '',
7075
selectedOptions: [],
@@ -185,6 +190,7 @@ class PillSelectorBase extends React.Component<Props, State> {
185190
className,
186191
disabled,
187192
error,
193+
errorTooltipPosition,
188194
getPillClassName,
189195
getPillImageUrl,
190196
inputProps,
@@ -219,7 +225,7 @@ class PillSelectorBase extends React.Component<Props, State> {
219225
};
220226

221227
return (
222-
<Tooltip isShown={hasError} text={error || ''} position="bottom-left" theme="error">
228+
<Tooltip isShown={hasError} text={error || ''} position={errorTooltipPosition} theme="error">
223229
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
224230
<span
225231
className={classes}

‎src/components/pill-selector-dropdown/PillSelectorDropdown.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import PillSelector from './PillSelector';
1212
import type { contactType as Contact } from '../../features/unified-share-modal/flowTypes';
1313
import type { SelectOptionProp } from '../select-field/props';
1414
import type { Option, OptionValue, SelectedOptions, SuggestedPillsFilter } from './flowTypes';
15+
import type { Position } from '../tooltip';
1516

1617
import './PillSelectorDropdown.scss';
1718

@@ -32,6 +33,8 @@ type Props = {
3233
dropdownScrollBoundarySelector?: string,
3334
/** Error message */
3435
error?: React.Node,
36+
/** Position of error message tooltip */
37+
errorTooltipPosition?: Position,
3538
/** Called on pill render to get a specific class name to use for a particular option. Note: Only has effect when showRoundedPills is true. */
3639
getPillClassName?: (option: Option) => string,
3740
/** Function to retrieve the image URL associated with a pill */
@@ -238,6 +241,7 @@ class PillSelectorDropdown extends React.Component<Props, State> {
238241
dividerIndex,
239242
dropdownScrollBoundarySelector,
240243
error,
244+
errorTooltipPosition,
241245
getPillClassName,
242246
getPillImageUrl,
243247
inputProps,
@@ -276,6 +280,7 @@ class PillSelectorDropdown extends React.Component<Props, State> {
276280
allowInvalidPills={allowInvalidPills}
277281
disabled={disabled}
278282
error={error}
283+
errorTooltipPosition={errorTooltipPosition}
279284
getPillClassName={getPillClassName}
280285
getPillImageUrl={getPillImageUrl}
281286
onBlur={this.handleBlur}

0 commit comments

Comments
 (0)