Skip to content

Commit

Permalink
chore: Update dom strcutrue
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Nov 28, 2019
1 parent df35d0e commit 0303edb
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,11 @@ function InnerPicker<DateType>(props: PickerProps<DateType>) {
/>
);

let suffixNode: React.ReactNode;
if (suffixIcon) {
suffixNode = <span className={`${prefixCls}-suffix`}>{suffixIcon}</span>;
}

let clearNode: React.ReactNode;
if (allowClear && mergedValue && !disabled) {
clearNode = (
Expand Down Expand Up @@ -430,7 +435,7 @@ function InnerPicker<DateType>(props: PickerProps<DateType>) {
placeholder={placeholder}
ref={inputRef}
/>
{suffixIcon}
{suffixNode}
{clearNode}
</div>
</PickerTrigger>
Expand Down
26 changes: 26 additions & 0 deletions tests/__snapshots__/picker.spec.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Basic icon 1`] = `
<div
class="rc-picker-input"
>
<input
readonly=""
value="1990-09-03"
/>
<span
class="rc-picker-suffix"
>
<span
class="suffix-icon"
/>
</span>
<span
class="rc-picker-clear"
>
<span
class="suffix-icon"
/>
</span>
</div>
`;
13 changes: 13 additions & 0 deletions tests/picker.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -431,4 +431,17 @@ describe('Basic', () => {
wrapper.find('.rc-picker-today-btn').simulate('click');
expect(isSame(onSelect.mock.calls[0][0], '1990-09-03')).toBeTruthy();
});

it('icon', () => {
const wrapper = mount(
<MomentPicker
defaultValue={getMoment('1990-09-03')}
suffixIcon={<span className="suffix-icon" />}
clearIcon={<span className="suffix-icon" />}
allowClear
/>,
);

expect(wrapper.find('.rc-picker-input').render()).toMatchSnapshot();
});
});

1 comment on commit 0303edb

@vercel
Copy link

@vercel vercel bot commented on 0303edb Nov 28, 2019

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.