Skip to content

Commit

Permalink
fix(select): fix select props classname error (#1003)
Browse files Browse the repository at this point in the history
Co-authored-by: shiliqian <shiliqian@growingio.com>
  • Loading branch information
berber1016 and shiliqian authored Jun 1, 2021
1 parent a59458b commit 764e9ee
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/components/select/Select.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import React from 'react';
import { withDesign } from 'storybook-addon-designs';
import { Story, Meta } from '@storybook/react/types-6-0';
import { FilterOutlined } from '@gio-design/icons';
import Select, { SelectProps } from './index';
import Docs from './Select.mdx';
import './style';
import Button from '../button';


export default {
title: 'Functional Components/Select',
Expand Down Expand Up @@ -41,7 +44,7 @@ const templatestEllipsisOptions = values.map((value, index) => ({
}))
const Template: Story<SelectProps> = (args) => (
<div>
<Select {...args} options={templatestEllipsisOptions} />
<Select {...args} triggerComponent={<Button type='text' size='small' icon={<FilterOutlined />} />} options={templatestEllipsisOptions} />
<br />
<br />
<Select {...args} style={{ width: '300px' }} />
Expand Down
3 changes: 2 additions & 1 deletion src/components/select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const Select = React.forwardRef<HTMLDivElement, SelectProps>(
allowCustomOption = false,
autoWidth = true,
allowDeselect = multiple,
triggerComponent,
notFoundContent,
customizePrefixCls,
className,
Expand Down Expand Up @@ -382,7 +383,7 @@ export const Select = React.forwardRef<HTMLDivElement, SelectProps>(
visible && onVisibleChange(!visible);
}
};
const trigger = (
const trigger = triggerComponent || (
<Selector
size={size}
input={input}
Expand Down
3 changes: 1 addition & 2 deletions src/components/select/Selector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ const Selector: React.ForwardRefRenderFunction<unknown, SelectorProps> = (props,
[`${prefix}-bordered`]: bordered,
[`${prefix}-focused`]: isFocused,
[`${prefix}-disabled`]: disabled,
className,
})}
},className)}
aria-disabled={disabled}
aria-hidden='true'
style={style}
Expand Down
5 changes: 5 additions & 0 deletions src/components/select/interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'lodash';
import React from 'react';
import { SizeType } from '../config-provider/SizeContext';

export type MaybeArray<T> = T | T[];
Expand Down Expand Up @@ -142,6 +143,10 @@ export interface SelectProps {
* 多选模式下 是否允许通过搜索自定义插入 option
*/
allowCustomOption?: boolean;
/**
* 被包裹的元素
*/
triggerComponent?: React.ReactElement;
/**
* 自定义无搜索内容
*/
Expand Down

1 comment on commit 764e9ee

@vercel
Copy link

@vercel vercel bot commented on 764e9ee Jun 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.