Skip to content

Commit 0303edb

Browse files
committed
chore: Update dom strcutrue
1 parent df35d0e commit 0303edb

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

src/Picker.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,11 @@ function InnerPicker<DateType>(props: PickerProps<DateType>) {
377377
/>
378378
);
379379

380+
let suffixNode: React.ReactNode;
381+
if (suffixIcon) {
382+
suffixNode = <span className={`${prefixCls}-suffix`}>{suffixIcon}</span>;
383+
}
384+
380385
let clearNode: React.ReactNode;
381386
if (allowClear && mergedValue && !disabled) {
382387
clearNode = (
@@ -430,7 +435,7 @@ function InnerPicker<DateType>(props: PickerProps<DateType>) {
430435
placeholder={placeholder}
431436
ref={inputRef}
432437
/>
433-
{suffixIcon}
438+
{suffixNode}
434439
{clearNode}
435440
</div>
436441
</PickerTrigger>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Basic icon 1`] = `
4+
<div
5+
class="rc-picker-input"
6+
>
7+
<input
8+
readonly=""
9+
value="1990-09-03"
10+
/>
11+
<span
12+
class="rc-picker-suffix"
13+
>
14+
<span
15+
class="suffix-icon"
16+
/>
17+
</span>
18+
<span
19+
class="rc-picker-clear"
20+
>
21+
<span
22+
class="suffix-icon"
23+
/>
24+
</span>
25+
</div>
26+
`;

tests/picker.spec.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,4 +431,17 @@ describe('Basic', () => {
431431
wrapper.find('.rc-picker-today-btn').simulate('click');
432432
expect(isSame(onSelect.mock.calls[0][0], '1990-09-03')).toBeTruthy();
433433
});
434+
435+
it('icon', () => {
436+
const wrapper = mount(
437+
<MomentPicker
438+
defaultValue={getMoment('1990-09-03')}
439+
suffixIcon={<span className="suffix-icon" />}
440+
clearIcon={<span className="suffix-icon" />}
441+
allowClear
442+
/>,
443+
);
444+
445+
expect(wrapper.find('.rc-picker-input').render()).toMatchSnapshot();
446+
});
434447
});

0 commit comments

Comments
 (0)