Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,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 => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ AsyncSelect.args = {
pageSize: 10,
withError: false,
withInitialValue: false,
tokenSeparators: ['\n', '\t', ';'],
};

AsyncSelect.argTypes = {
Expand Down
4 changes: 3 additions & 1 deletion superset-frontend/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type PickedSelectProps = Pick<
| 'onDropdownVisibleChange'
| 'placeholder'
| 'showSearch'
| 'tokenSeparators'
| 'value'
>;

Expand Down Expand Up @@ -310,6 +311,7 @@ const Select = (
placeholder = t('Select ...'),
showSearch = true,
sortComparator = DEFAULT_SORT_COMPARATOR,
tokenSeparators,
value,
...props
}: SelectProps,
Expand Down Expand Up @@ -706,7 +708,7 @@ const Select = (
placeholder={placeholder}
showSearch={shouldShowSearch}
showArrow
tokenSeparators={TOKEN_SEPARATORS}
tokenSeparators={tokenSeparators || TOKEN_SEPARATORS}
value={selectValue}
suffixIcon={getSuffixIcon()}
menuItemSelectedIcon={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -177,6 +178,7 @@ export default class SelectControl extends React.PureComponent {
optionRenderer,
showHeader,
value,
tokenSeparators,
// ControlHeader props
description,
renderTrigger,
Expand Down Expand Up @@ -242,6 +244,7 @@ export default class SelectControl extends React.PureComponent {
placeholder,
sortComparator: this.props.sortComparator,
value: getValue(),
tokenSeparators,
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down