From caea1acfbe845ac12a92facda32ae7ed85e4ccc0 Mon Sep 17 00:00:00 2001 From: John60676 Date: Tue, 29 Sep 2020 18:30:39 +0800 Subject: [PATCH 1/7] fix(select): click on the selected item can deselect (#2920) --- components/vc-select/Select.jsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/vc-select/Select.jsx b/components/vc-select/Select.jsx index 3a4a74012..9941464d3 100644 --- a/components/vc-select/Select.jsx +++ b/components/vc-select/Select.jsx @@ -482,6 +482,11 @@ const Select = { } return; } + + if (domEvent.type === 'click') { + this.removeSelected(getValuePropValue(item)); + } + if (this.autoClearSearchValue) { this.setInputValue(''); } From 51fb7cd8885cd6ba8ce91173b31a442c3eb6306b Mon Sep 17 00:00:00 2001 From: zkwolf Date: Tue, 29 Sep 2020 22:09:29 +0800 Subject: [PATCH 2/7] feat: tree support global tree slot (#2904) --- components/tree/Tree.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/tree/Tree.jsx b/components/tree/Tree.jsx index ef301c293..8a0fb12b1 100644 --- a/components/tree/Tree.jsx +++ b/components/tree/Tree.jsx @@ -161,7 +161,11 @@ export default { $slots[scopedSlots.switcherIcon] || $slots[slots.switcherIcon] || restProps.switcherIcon, - title: $slots[scopedSlots.title] || $slots[slots.title] || restProps[replaceFields.title], + title: + $slots[scopedSlots.title] || + $slots[slots.title] || + $slots.title || + restProps[replaceFields.title], dataRef: item, key, class: cls, From ca2c77e4bd913833583e617d971b933052484cfc Mon Sep 17 00:00:00 2001 From: John60676 Date: Tue, 29 Sep 2020 22:11:06 +0800 Subject: [PATCH 3/7] refactor(input): update input style (#2876) * refactor(input): update input style * refactor(form): update form style about input component * refactor(input): update clearable icon style Modify the clearable icon style to prevent the width of the input box from changing due to the insertion of the icon --- components/form/style/index.less | 12 ---- components/input/ClearableLabeledInput.jsx | 26 +++++--- components/input/Input.jsx | 26 +++++++- components/input/style/index.less | 8 +++ components/input/style/mixin.less | 73 +++++++++++----------- components/style/themes/default.less | 2 +- 6 files changed, 87 insertions(+), 60 deletions(-) diff --git a/components/form/style/index.less b/components/form/style/index.less index 1967010e3..97d41fcfe 100644 --- a/components/form/style/index.less +++ b/components/form/style/index.less @@ -136,23 +136,11 @@ form { .has-feedback { - .@{ant-prefix}-input { - padding-right: @input-padding-horizontal-base + @input-affix-width; - } - // https://github.com/ant-design/ant-design/issues/19884 .@{ant-prefix}-input-affix-wrapper { .@{ant-prefix}-input-suffix { padding-right: 18px; } - .@{ant-prefix}-input { - padding-right: @input-padding-horizontal-base + @input-affix-width * 2; - } - &.@{ant-prefix}-input-affix-wrapper-input-with-clear-btn { - .@{ant-prefix}-input { - padding-right: @input-padding-horizontal-base + @input-affix-width * 3; - } - } } // Fix overlapping between feedback icon and `; exports[`TextArea should support maxlength 1`] = ``; + +exports[`TextArea should support showCount 1`] = `
`; diff --git a/components/input/__tests__/index.test.js b/components/input/__tests__/index.test.js index d70d261cf..684411905 100644 --- a/components/input/__tests__/index.test.js +++ b/components/input/__tests__/index.test.js @@ -29,7 +29,7 @@ describe('Input', () => { props: { allowClear: true, defaultValue: '111', disabled: true }, sync: false, }); - expect(wrapper.findAll('.ant-input-clear-icon').length).toBe(0); + expect(wrapper.findAll('.ant-input-clear-icon-hidden').length).toBeTruthy(); }); }); @@ -68,6 +68,17 @@ describe('TextArea', () => { expect(wrapper.html()).toMatchSnapshot(); }); }); + + it('should support showCount', async () => { + const wrapper = mount(TextArea, { + props: { showCount: true, defaultValue: '111', maxlength: 10 }, + sync: false, + }); + expect(wrapper.find('.ant-input-textarea-show-count')).toBeTruthy(); + await asyncExpect(() => { + expect(wrapper.html()).toMatchSnapshot(); + }); + }); }); // describe('As Form Control', () => { diff --git a/components/input/style/index.less b/components/input/style/index.less index 8acafd416..c41058460 100644 --- a/components/input/style/index.less +++ b/components/input/style/index.less @@ -57,4 +57,13 @@ margin: 8px 8px 0 0; } +.@{ant-prefix}-input-textarea { + &-show-count::after { + display: block; + color: @text-color-secondary; + text-align: right; + content: attr(data-count); + } +} + @import './search-input'; diff --git a/types/input/textarea.d.ts b/types/input/textarea.d.ts index a30389a27..0ea21fa15 100644 --- a/types/input/textarea.d.ts +++ b/types/input/textarea.d.ts @@ -31,5 +31,6 @@ export declare class TextArea extends AntdComponent { * @type boolean */ allowClear?: boolean; + showCount?: boolean; }; }