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 11 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 @@ -440,6 +440,7 @@ const y_axis_format: SharedControlConfig<'SelectControl'> = {
default: DEFAULT_NUMBER_FORMAT,
choices: D3_FORMAT_OPTIONS,
description: D3_FORMAT_DOCS,
tokenSeparators: ['\n', '\t', ';'],
mapStateToProps: state => {
const showWarning = state.controls?.comparison_type?.value === 'percentage';
return {
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
5 changes: 3 additions & 2 deletions 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 @@ -299,13 +300,13 @@ const Select = (
onError,
onChange,
onClear,
onDropdownVisibleChange,
prosdev0107 marked this conversation as resolved.
Show resolved Hide resolved
optionFilterProps = ['label', 'value'],
options,
pageSize = DEFAULT_PAGE_SIZE,
placeholder = t('Select ...'),
showSearch = true,
sortComparator = DEFAULT_SORT_COMPARATOR,
tokenSeparators,
value,
...props
}: SelectProps,
Expand Down Expand Up @@ -690,7 +691,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 @@ -178,6 +179,7 @@ export default class SelectControl extends React.PureComponent {
optionRenderer,
showHeader,
value,
tokenSeparators,
// ControlHeader props
description,
renderTrigger,
Expand Down Expand Up @@ -243,6 +245,7 @@ export default class SelectControl extends React.PureComponent {
placeholder,
sortComparator: this.props.sortComparator || propertyComparator('order'),
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