From 26c61a12d5ae3b59b8a1dd42b834b7514a2d9d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=81=8F=E5=8F=B3?= Date: Mon, 26 Aug 2019 22:58:00 +0800 Subject: [PATCH] :bug: Input disabled should not be allowed to clear (#18482) close #18481 --- components/input/Input.tsx | 4 ++-- components/input/__tests__/index.test.js | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/components/input/Input.tsx b/components/input/Input.tsx index 4d4df0157e..f92060c01b 100644 --- a/components/input/Input.tsx +++ b/components/input/Input.tsx @@ -180,9 +180,9 @@ class Input extends React.Component { } renderClearIcon(prefixCls: string) { - const { allowClear } = this.props; + const { allowClear, disabled } = this.props; const { value } = this.state; - if (!allowClear || value === undefined || value === null || value === '') { + if (!allowClear || disabled || value === undefined || value === null || value === '') { return null; } return ( diff --git a/components/input/__tests__/index.test.js b/components/input/__tests__/index.test.js index 3ea12bba07..a16adc405a 100644 --- a/components/input/__tests__/index.test.js +++ b/components/input/__tests__/index.test.js @@ -308,4 +308,9 @@ describe('Input allowClear', () => { .getDOMNode(), ); }); + + it('should not support allowClear when it is disabled', () => { + const wrapper = mount(); + expect(wrapper.find('.ant-input-clear-icon').length).toBe(0); + }); });