Skip to content

Commit

Permalink
fix: select TagRender Property not open dropdown when click (#582)
Browse files Browse the repository at this point in the history
* fix: select TagRender Property not open dropdown when click

* test: update testcase

* test: update testCase

* test: update testCase
  • Loading branch information
mumiao authored Dec 28, 2020
1 parent 0ae299c commit 125e5ef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Selector/MultipleSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface SelectorProps extends InnerSelectorProps {
maxTagPlaceholder?: React.ReactNode | ((omittedValues: LabelValueType[]) => React.ReactNode);
tokenSeparators?: string[];
tagRender?: (props: CustomTagProps) => React.ReactElement;
onToggleOpen: (open?: boolean) => void;

// Motion
choiceTransitionName?: string;
Expand Down Expand Up @@ -62,6 +63,7 @@ const SelectSelector: React.FC<SelectorProps> = props => {
maxTagTextLength,
maxTagPlaceholder = (omittedValues: LabelValueType[]) => `+ ${omittedValues.length} ...`,
tagRender,
onToggleOpen,

onSelect,
onInputChange,
Expand Down Expand Up @@ -123,8 +125,13 @@ const SelectSelector: React.FC<SelectorProps> = props => {
closable: boolean,
onClose: React.MouseEventHandler,
) {
const onMouseDown = (e: React.MouseEvent) => {
onPreventMouseDown(e);
onToggleOpen(true);
};

return (
<span onMouseDown={onPreventMouseDown}>
<span onMouseDown={onMouseDown}>
{tagRender({
label: content,
value,
Expand Down
2 changes: 2 additions & 0 deletions tests/Tags.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ describe('Select.Tags', () => {
const wrapper = mount(<Select mode="tags" tokenSeparators={[',']} tagRender={tagRender} />);

wrapper.find('input').simulate('change', { target: { value: '1,A,42' } });
wrapper.find('span.A').simulate('mousedown');

expectOpen(wrapper, true);
expect(wrapper.find('span.A').length).toBe(1);
expect(wrapper.find('span.A').text()).toBe('AA');
expect(onTagRender).toHaveBeenCalled();
Expand Down

1 comment on commit 125e5ef

@vercel
Copy link

@vercel vercel bot commented on 125e5ef Dec 28, 2020

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.