Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit349986e

Browse files
fix number input 'allow null value' has no effect
1 parentd7daf28 commit349986e

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

‎client/packages/lowcoder/src/comps/comps/numberInputComp/numberInputComp.tsx‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import{BoolControl}from"comps/controls/boolControl";
1111
import{dropdownControl}from"comps/controls/dropdownControl";
1212
import{LabelControl}from"comps/controls/labelControl";
13-
import{numberExposingStateControl}from"comps/controls/codeStateControl";
13+
import{numberExposingStateControl,stringExposingStateControl}from"comps/controls/codeStateControl";
1414
importNPfrom"number-precision";
1515

1616
import{
@@ -234,6 +234,7 @@ const UndefinedNumberControl = codeControl<number | undefined>((value: any) => {
234234
});
235235

236236
constchildrenMap={
237+
defaultValue:stringExposingStateControl("defaultValue"),// It is more convenient for string to handle various states, save raw input here
237238
value:numberExposingStateControl("value"),// It is more convenient for string to handle various states, save raw input here
238239
placeholder:StringControl,
239240
disabled:BoolCodeControl,
@@ -261,6 +262,17 @@ const childrenMap = {
261262

262263
constCustomInputNumber=(props:RecordConstructorToView<typeofchildrenMap>)=>{
263264
constref=useRef<HTMLInputElement|null>(null);
265+
constdefaultValue=props.defaultValue.value;
266+
267+
useEffect(()=>{
268+
letvalue=0;
269+
if(defaultValue==='null'&&props.allowNull){
270+
value=NaN;
271+
}elseif(!isNaN(Number(defaultValue))){
272+
value=Number(defaultValue);
273+
}
274+
props.value.onChange(value);
275+
},[defaultValue]);
264276

265277
constformatFn=(value:number)=>
266278
format(value,props.allowNull,props.formatter,props.precision,props.thousandsSeparator);
@@ -271,7 +283,9 @@ const CustomInputNumber = (props: RecordConstructorToView<typeof childrenMap>) =
271283
constoldValue=props.value.value;
272284
constnewValue=parseNumber(tmpValue,props.allowNull);
273285
props.value.onChange(newValue);
274-
oldValue!==newValue&&props.onEvent("change");
286+
if((oldValue!==newValue)){
287+
props.onEvent("change");
288+
}
275289
};
276290

277291
useEffect(()=>{
@@ -363,7 +377,7 @@ const NumberInputTmpComp = (function () {
363377
.setPropertyViewFn((children)=>(
364378
<>
365379
<Sectionname={sectionNames.basic}>
366-
{children.value.propertyView({label:trans("prop.defaultValue")})}
380+
{children.defaultValue.propertyView({label:trans("prop.defaultValue")})}
367381
{placeholderPropertyView(children)}
368382
{children.formatter.propertyView({label:trans("numberInput.formatter")})}
369383
</Section>

‎client/packages/lowcoder/src/comps/controls/dropdownControl.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ export function dropdownAbstractControl<T extends OptionsType>(
9696
value={this.value}
9797
options={finalOptions}
9898
onChange={(value)=>{
99-
console.log(value);
10099
if(!params.disableDispatchValueChange){
101100
this.dispatchChangeValueAction(value);
102101
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp