Skip to content

Commit 507195f

Browse files
committed
fix: input clear style
1 parent 8a363ca commit 507195f

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

Diff for: components/input/Input.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ export default {
123123
},
124124

125125
renderClearIcon(prefixCls) {
126-
const { allowClear } = this.$props;
126+
const { allowClear, disabled } = this.$props;
127127
const { stateValue } = this;
128-
if (!allowClear || stateValue === undefined || stateValue === null || stateValue === '') {
128+
if (!allowClear || disabled || stateValue === undefined || stateValue === null || stateValue === '') {
129129
return null;
130130
}
131131
return (

Diff for: components/input/__tests__/index.test.js

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ describe('Input', () => {
1919
const wrapper = mount(Input);
2020
wrapper.vm.select();
2121
});
22+
23+
it('should not support allowClear when it is disabled', () => {
24+
const wrapper = mount(Input, {
25+
propsData: { allowClear: true, defaultValue: '111', disabled: true },
26+
sync: false,
27+
});
28+
expect(wrapper.findAll('.ant-input-clear-icon').length).toBe(0);
29+
});
2230
});
2331

2432
focusTest(TextArea);

Diff for: components/input/style/index.less

+23
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,27 @@
3939
}
4040
}
4141

42+
// fix style #1296, remove annotation when upgrade ant-design version > 3.21.3
43+
.@{ant-prefix}-input-clear-icon {
44+
color: @disabled-color;
45+
font-size: @font-size-sm;
46+
// https://github.com/ant-design/ant-design/pull/18151
47+
// https://codesandbox.io/s/wizardly-sun-u10br
48+
vertical-align: 0;
49+
cursor: pointer;
50+
transition: color 0.3s;
51+
52+
&:hover {
53+
color: @text-color-secondary;
54+
}
55+
56+
&:active {
57+
color: @text-color;
58+
}
59+
60+
+ i {
61+
margin-left: 6px;
62+
}
63+
}
64+
4265
@import './search-input';

Diff for: components/input/style/mixin.less

+2
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@
363363
position: absolute;
364364
top: 50%;
365365
z-index: 2;
366+
display: flex;
367+
align-items: center;
366368
color: @input-color;
367369
line-height: 0;
368370
transform: translateY(-50%);

0 commit comments

Comments
 (0)