From ec9b2c45840e24da982151cdaaf09d7615cbdc8e Mon Sep 17 00:00:00 2001 From: Liu Xin Date: Mon, 23 Oct 2023 16:29:22 +0800 Subject: [PATCH] fix: Optimize the tag input to automatically fill in the value when it loses focus (#4225) Signed-off-by: harrisonliu5 --- package.json | 2 +- .../BaseForm/ConditionSelect/index.jsx | 25 ++++++++++++++++--- .../Inputs/TagInput/autosuggest.jsx | 16 ++++++++++++ src/components/Inputs/TagInput/index.scss | 5 ++-- yarn.lock | 8 +++--- 5 files changed, 44 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 6a93ea5547f..cd3a67e2fde 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "license": "AGPL-3.0", "dependencies": { "@babel/polyfill": "^7.12.1", - "@kube-design/components": "^1.27.1", + "@kube-design/components": "^1.32.0", "ace-builds": "^1.4.7", "ansi_up": "^5.0.0", "async-validator": "^1.8.5", diff --git a/src/components/Forms/Notification/BaseForm/ConditionSelect/index.jsx b/src/components/Forms/Notification/BaseForm/ConditionSelect/index.jsx index c6475c0c56c..7ff5355aa1d 100644 --- a/src/components/Forms/Notification/BaseForm/ConditionSelect/index.jsx +++ b/src/components/Forms/Notification/BaseForm/ConditionSelect/index.jsx @@ -134,7 +134,13 @@ export default class ConditionSelect extends React.Component { } handleOperatorChange = operator => { - this.setState({ operator }, () => this.handleChange()) + let values = this.state.values + + if (['Exists', 'DoesNotExist'].includes(operator)) { + values = undefined + } + + this.setState({ operator, values }, () => this.handleChange()) } handleValueChange = values => { @@ -143,12 +149,20 @@ export default class ConditionSelect extends React.Component { handleChange = () => { const { key, operator, values } = this.state + const _values = ['Exists', 'DoesNotExist'].includes(operator) + ? undefined + : values || [] - this.props.onChange({ + const data = { key, operator, - values: ['Exists', 'DoesNotExist'].includes(operator) ? [] : values, - }) + } + + if (_values) { + data.values = _values + } + + this.props.onChange(data) } dorpdownRender = options => { @@ -173,9 +187,11 @@ export default class ConditionSelect extends React.Component { renderValues() { const { key, operator, values } = this.state + if (operator === 'Exists' || operator === 'DoesNotExist') { return null } + if (key === 'severity') { return (