fix(explore comma): make that the comma can be added by removing it from token separators… (#18926)

* make that the comma can be added by removing it from token separators in select component.

* fix(explore comma): add the allowTokenSeperators props into Select

* fix(explore comma): make to allow to customize the token separators in Select.

* fix(explore comma): make to add the unit test and story book.

* fix(explore comma): make to fix the lint

* fix(explore comma): make to fix the spell  & add tokenSeparatprs props to PickedSelectProps

* Update Select.tsx

* fix(explore comma): make to run lint fix
This commit is contained in:
smileydev 2022-03-18 10:39:26 -04:00 committed by GitHub
parent 2a89da2ef1
commit e7355b9610
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 1 deletions

View File

@ -448,6 +448,7 @@ const y_axis_format: SharedControlConfig<'SelectControl', SelectDefaultOption> =
default: DEFAULT_NUMBER_FORMAT,
choices: D3_FORMAT_OPTIONS,
description: D3_FORMAT_DOCS,
tokenSeparators: ['\n', '\t', ';'],
filterOption: ({ data: option }, search) =>
option.label.includes(search) || option.value.includes(search),
mapStateToProps: state => {

View File

@ -495,6 +495,7 @@ AsyncSelect.args = {
pageSize: 10,
withError: false,
withInitialValue: false,
tokenSeparators: ['\n', '\t', ';'],
};
AsyncSelect.argTypes = {

View File

@ -64,6 +64,7 @@ type PickedSelectProps = Pick<
| 'onDropdownVisibleChange'
| 'placeholder'
| 'showSearch'
| 'tokenSeparators'
| 'value'
>;
@ -310,6 +311,7 @@ const Select = (
placeholder = t('Select ...'),
showSearch = true,
sortComparator = DEFAULT_SORT_COMPARATOR,
tokenSeparators,
value,
...props
}: SelectProps,
@ -706,7 +708,7 @@ const Select = (
placeholder={placeholder}
showSearch={shouldShowSearch}
showArrow
tokenSeparators={TOKEN_SEPARATORS}
tokenSeparators={tokenSeparators || TOKEN_SEPARATORS}
value={selectValue}
suffixIcon={getSuffixIcon()}
menuItemSelectedIcon={

View File

@ -52,6 +52,7 @@ const propTypes = {
options: PropTypes.array,
placeholder: PropTypes.string,
filterOption: PropTypes.func,
tokenSeparators: PropTypes.arrayOf(PropTypes.string),
// ControlHeader props
label: PropTypes.string,
@ -177,6 +178,7 @@ export default class SelectControl extends React.PureComponent {
optionRenderer,
showHeader,
value,
tokenSeparators,
// ControlHeader props
description,
renderTrigger,
@ -242,6 +244,7 @@ export default class SelectControl extends React.PureComponent {
placeholder,
sortComparator: this.props.sortComparator,
value: getValue(),
tokenSeparators,
};
return (

View File

@ -78,6 +78,14 @@ describe('SelectControl', () => {
expect(wrapper.find(SelectComponent).prop('allowNewOptions')).toBe(false);
});
it('renders with tokenSeparators', () => {
wrapper.setProps({ tokenSeparators: ['\n', '\t', ';'] });
expect(wrapper.find(SelectComponent)).toExist();
expect(wrapper.find(SelectComponent).prop('tokenSeparators')).toEqual(
expect.arrayContaining([expect.any(String)]),
);
});
describe('empty placeholder', () => {
describe('withMulti', () => {
it('does not show a placeholder if there are no choices', () => {