Fix input clean error
This commit is contained in:
parent
f3ba3b6150
commit
0e1aa51d4b
@ -1,9 +1,12 @@
|
|||||||
@import "../Theme/Theme.scss";
|
@import "../Theme/Theme.scss";
|
||||||
|
|
||||||
|
$line-min-height: 24px;
|
||||||
|
$root-min-height: 26px;
|
||||||
|
|
||||||
div.attr-input {
|
div.attr-input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
min-height: 24px;
|
min-height: $line-min-height;
|
||||||
padding: 5px 0;
|
padding: 5px 0;
|
||||||
|
|
||||||
div.input-intro {
|
div.input-intro {
|
||||||
@ -20,6 +23,7 @@ div.attr-input {
|
|||||||
width: 50%;
|
width: 50%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
max-width: 180px;
|
max-width: 180px;
|
||||||
|
min-height: $root-min-height;
|
||||||
|
|
||||||
div.input-content {
|
div.input-content {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@ -29,13 +33,14 @@ div.attr-input {
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
min-height: 24px;
|
min-height: $root-min-height;
|
||||||
|
|
||||||
input {
|
input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
border: none;
|
border: none;
|
||||||
outline:none;
|
outline:none;
|
||||||
|
min-height: $line-min-height;
|
||||||
};
|
};
|
||||||
|
|
||||||
input:focus {
|
input:focus {
|
||||||
@ -43,7 +48,7 @@ div.attr-input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
div.button-left, div.button-right {
|
div.button-left, div.button-right {
|
||||||
min-height: 24px;
|
min-height: $line-min-height;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@ -66,7 +71,7 @@ div.attr-input {
|
|||||||
div.err-message {
|
div.err-message {
|
||||||
color: $lt-red;
|
color: $lt-red;
|
||||||
padding-top: 5px;
|
padding-top: 5px;
|
||||||
min-height: 24px;
|
min-height: $line-min-height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,10 @@ class AttrInput extends Component<IAttrInputProps> {
|
|||||||
|
|
||||||
private handelValueChange = () => {
|
private handelValueChange = () => {
|
||||||
if (!this.error && this.props.valueChange) {
|
if (!this.error && this.props.valueChange) {
|
||||||
|
if (this.props.isNumber) {
|
||||||
|
let numberVal = (this.value as any) * 10000;
|
||||||
|
this.value = (Math.round(numberVal) / 10000).toString();
|
||||||
|
}
|
||||||
this.props.valueChange(this.value);
|
this.props.valueChange(this.value);
|
||||||
}
|
}
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
@ -122,14 +126,19 @@ class AttrInput extends Component<IAttrInputProps> {
|
|||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
public render(): ReactNode {
|
public shouldComponentUpdate(nextProps: IAttrInputProps) {
|
||||||
|
this.updateValueFromProps(nextProps.value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.error) {
|
private updateValueFromProps(val: IAttrInputProps["value"]) {
|
||||||
const value = this.props.value ?? (this.props.isNumber ? "0" : "");
|
const value = val ?? (this.props.isNumber ? "0" : "");
|
||||||
this.value = value.toString();
|
this.value = value.toString();
|
||||||
this.error = this.check(value.toString());
|
this.error = this.check(value.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public render(): ReactNode {
|
||||||
|
|
||||||
return <Theme
|
return <Theme
|
||||||
className="attr-input"
|
className="attr-input"
|
||||||
fontLevel={FontLevel.normal}
|
fontLevel={FontLevel.normal}
|
||||||
|
@ -74,7 +74,7 @@ class Layout extends Emitter<ILayoutEvent> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public focus = (panelId: string) => {
|
public focus = (panelId: string) => {
|
||||||
if (panelId === "") {
|
if (panelId === "" && this.focusId !== "") {
|
||||||
this.focusId = panelId;
|
this.focusId = panelId;
|
||||||
this.emit("switchTab", this);
|
this.emit("switchTab", this);
|
||||||
}
|
}
|
||||||
@ -89,12 +89,16 @@ class Layout extends Emitter<ILayoutEvent> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
|
if (layout.focusPanel === panelId && this.focusId === panelId) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
layout.focusPanel = panelId;
|
layout.focusPanel = panelId;
|
||||||
this.focusId = panelId;
|
this.focusId = panelId;
|
||||||
this.emit("switchTab", this);
|
this.emit("switchTab", this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -40,17 +40,27 @@ class RangeDetails extends Component<IMixinStatusProps> {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<AttrInput
|
<AttrInput
|
||||||
|
isNumber={true}
|
||||||
|
step={.1}
|
||||||
keyI18n="Common.Attr.Key.Position.Y"
|
keyI18n="Common.Attr.Key.Position.Y"
|
||||||
value={range.position[1]}
|
value={range.position[1]}
|
||||||
valueChange={(e) => {
|
valueChange={(e) => {
|
||||||
this.props.status ? this.props.status.changeRangeAttrib(range.id, "displayName", e) : null;
|
if (this.props.status) {
|
||||||
|
range.position[1] = (e as any) / 1;
|
||||||
|
this.props.status.changeRangeAttrib(range.id, "position", range.position);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<AttrInput
|
<AttrInput
|
||||||
|
isNumber={true}
|
||||||
|
step={.1}
|
||||||
keyI18n="Common.Attr.Key.Position.Z"
|
keyI18n="Common.Attr.Key.Position.Z"
|
||||||
value={range.position[2]}
|
value={range.position[2]}
|
||||||
valueChange={(e) => {
|
valueChange={(e) => {
|
||||||
this.props.status ? this.props.status.changeRangeAttrib(range.id, "displayName", e) : null;
|
if (this.props.status) {
|
||||||
|
range.position[2] = (e as any) / 1;
|
||||||
|
this.props.status.changeRangeAttrib(range.id, "position", range.position);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
Loading…
Reference in New Issue
Block a user