mirror of https://github.com/apache/superset.git
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:
parent
2a89da2ef1
commit
e7355b9610
|
@ -448,6 +448,7 @@ const y_axis_format: SharedControlConfig<'SelectControl', SelectDefaultOption> =
|
||||||
default: DEFAULT_NUMBER_FORMAT,
|
default: DEFAULT_NUMBER_FORMAT,
|
||||||
choices: D3_FORMAT_OPTIONS,
|
choices: D3_FORMAT_OPTIONS,
|
||||||
description: D3_FORMAT_DOCS,
|
description: D3_FORMAT_DOCS,
|
||||||
|
tokenSeparators: ['\n', '\t', ';'],
|
||||||
filterOption: ({ data: option }, search) =>
|
filterOption: ({ data: option }, search) =>
|
||||||
option.label.includes(search) || option.value.includes(search),
|
option.label.includes(search) || option.value.includes(search),
|
||||||
mapStateToProps: state => {
|
mapStateToProps: state => {
|
||||||
|
|
|
@ -495,6 +495,7 @@ AsyncSelect.args = {
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
withError: false,
|
withError: false,
|
||||||
withInitialValue: false,
|
withInitialValue: false,
|
||||||
|
tokenSeparators: ['\n', '\t', ';'],
|
||||||
};
|
};
|
||||||
|
|
||||||
AsyncSelect.argTypes = {
|
AsyncSelect.argTypes = {
|
||||||
|
|
|
@ -64,6 +64,7 @@ type PickedSelectProps = Pick<
|
||||||
| 'onDropdownVisibleChange'
|
| 'onDropdownVisibleChange'
|
||||||
| 'placeholder'
|
| 'placeholder'
|
||||||
| 'showSearch'
|
| 'showSearch'
|
||||||
|
| 'tokenSeparators'
|
||||||
| 'value'
|
| 'value'
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
@ -310,6 +311,7 @@ const Select = (
|
||||||
placeholder = t('Select ...'),
|
placeholder = t('Select ...'),
|
||||||
showSearch = true,
|
showSearch = true,
|
||||||
sortComparator = DEFAULT_SORT_COMPARATOR,
|
sortComparator = DEFAULT_SORT_COMPARATOR,
|
||||||
|
tokenSeparators,
|
||||||
value,
|
value,
|
||||||
...props
|
...props
|
||||||
}: SelectProps,
|
}: SelectProps,
|
||||||
|
@ -706,7 +708,7 @@ const Select = (
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
showSearch={shouldShowSearch}
|
showSearch={shouldShowSearch}
|
||||||
showArrow
|
showArrow
|
||||||
tokenSeparators={TOKEN_SEPARATORS}
|
tokenSeparators={tokenSeparators || TOKEN_SEPARATORS}
|
||||||
value={selectValue}
|
value={selectValue}
|
||||||
suffixIcon={getSuffixIcon()}
|
suffixIcon={getSuffixIcon()}
|
||||||
menuItemSelectedIcon={
|
menuItemSelectedIcon={
|
||||||
|
|
|
@ -52,6 +52,7 @@ const propTypes = {
|
||||||
options: PropTypes.array,
|
options: PropTypes.array,
|
||||||
placeholder: PropTypes.string,
|
placeholder: PropTypes.string,
|
||||||
filterOption: PropTypes.func,
|
filterOption: PropTypes.func,
|
||||||
|
tokenSeparators: PropTypes.arrayOf(PropTypes.string),
|
||||||
|
|
||||||
// ControlHeader props
|
// ControlHeader props
|
||||||
label: PropTypes.string,
|
label: PropTypes.string,
|
||||||
|
@ -177,6 +178,7 @@ export default class SelectControl extends React.PureComponent {
|
||||||
optionRenderer,
|
optionRenderer,
|
||||||
showHeader,
|
showHeader,
|
||||||
value,
|
value,
|
||||||
|
tokenSeparators,
|
||||||
// ControlHeader props
|
// ControlHeader props
|
||||||
description,
|
description,
|
||||||
renderTrigger,
|
renderTrigger,
|
||||||
|
@ -242,6 +244,7 @@ export default class SelectControl extends React.PureComponent {
|
||||||
placeholder,
|
placeholder,
|
||||||
sortComparator: this.props.sortComparator,
|
sortComparator: this.props.sortComparator,
|
||||||
value: getValue(),
|
value: getValue(),
|
||||||
|
tokenSeparators,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -78,6 +78,14 @@ describe('SelectControl', () => {
|
||||||
expect(wrapper.find(SelectComponent).prop('allowNewOptions')).toBe(false);
|
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('empty placeholder', () => {
|
||||||
describe('withMulti', () => {
|
describe('withMulti', () => {
|
||||||
it('does not show a placeholder if there are no choices', () => {
|
it('does not show a placeholder if there are no choices', () => {
|
||||||
|
|
Loading…
Reference in New Issue