diff --git a/source/Component/AttrInput/AttrInput.tsx b/source/Component/AttrInput/AttrInput.tsx index 37213fa..d798072 100644 --- a/source/Component/AttrInput/AttrInput.tsx +++ b/source/Component/AttrInput/AttrInput.tsx @@ -3,8 +3,10 @@ import { FontLevel, Theme } from "@Component/Theme/Theme"; import "./AttrInput.scss"; import { Icon } from "@fluentui/react"; import { Localization, AllI18nKeys } from "@Component/Localization/Localization"; +import { ObjectID } from "@Model/Renderer"; interface IAttrInputProps { + id?: ObjectID; keyI18n: AllI18nKeys; infoI18n?: AllI18nKeys; value?: number | string; @@ -35,7 +37,7 @@ class AttrInput extends Component { const praseNumber = (value as any) / 1; // 数字校验 - if (isNaN(praseNumber)) { + if (isNaN(praseNumber) || /\.0*$/.test(value)) { return } @@ -127,7 +129,16 @@ class AttrInput extends Component { } public shouldComponentUpdate(nextProps: IAttrInputProps) { - this.updateValueFromProps(nextProps.value); + + // ID 都为空时更新 + if (!nextProps.id && !this.props.id) { + this.updateValueFromProps(nextProps.value); + } + + // ID 变换时更新 State 到最新的 Props + if (nextProps.id !== this.props.id) { + this.updateValueFromProps(nextProps.value); + } return true; } diff --git a/source/Panel/RangeDetails/RangeDetails.tsx b/source/Panel/RangeDetails/RangeDetails.tsx index d54160a..21c944d 100644 --- a/source/Panel/RangeDetails/RangeDetails.tsx +++ b/source/Panel/RangeDetails/RangeDetails.tsx @@ -21,6 +21,7 @@ class RangeDetails extends Component { private renderFrom(range: Range) { return <> { @@ -28,6 +29,7 @@ class RangeDetails extends Component { }} /> { }} /> { }} />