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(select): fix select props classname error #1003

Merged
merged 1 commit into from
Jun 1, 2021
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
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