Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions app/client/src/widgets/SelectWidget/widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -893,14 +893,15 @@ class SelectWidget extends BaseWidget<SelectWidgetProps, WidgetState> {
if (!isNil(this.props.selectedOptionValue)) {
isChanged = this.props.selectedOptionValue !== selectedOption.value;
}
const { commitBatchMetaUpdates, pushBatchMetaUpdates } = this.props;
if (isChanged) {
if (!this.props.isDirty) {
this.props.updateWidgetMetaProperty("isDirty", true);
pushBatchMetaUpdates("isDirty", true);
}

this.props.updateWidgetMetaProperty("label", selectedOption.label ?? "");
pushBatchMetaUpdates("label", selectedOption.label ?? "");

this.props.updateWidgetMetaProperty("value", selectedOption.value ?? "", {
pushBatchMetaUpdates("value", selectedOption.value ?? "", {
triggerPropertyName: "onOptionChange",
dynamicString: this.props.onOptionChange,
event: {
Expand All @@ -911,8 +912,9 @@ class SelectWidget extends BaseWidget<SelectWidgetProps, WidgetState> {

// When Label changes but value doesnt change, Applies to serverside Filtering
if (!isChanged && this.props.selectedOptionLabel !== selectedOption.label) {
this.props.updateWidgetMetaProperty("label", selectedOption.label ?? "");
pushBatchMetaUpdates("label", selectedOption.label ?? "");
}
commitBatchMetaUpdates();
};

onFilterChange = (value: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,19 @@ class WDSCheckboxGroupWidget extends BaseWidget<
}

onChange = (selectedValues: OptionProps["value"][]) => {
const { commitBatchMetaUpdates, pushBatchMetaUpdates } = this.props;
if (!this.props.isDirty) {
this.props.updateWidgetMetaProperty("isDirty", true);
pushBatchMetaUpdates("isDirty", true);
}

this.props.updateWidgetMetaProperty("selectedValues", selectedValues, {
pushBatchMetaUpdates("selectedValues", selectedValues, {
triggerPropertyName: "onCheckChange",
dynamicString: this.props.onCheckChange,
event: {
type: EventType.ON_CHECKBOX_GROUP_SELECTION_CHANGE,
},
});
commitBatchMetaUpdates();
};

getWidgetView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,19 @@ class WDSCheckboxWidget extends BaseWidget<CheckboxWidgetProps, WidgetState> {
}

onChange = (isChecked: boolean) => {
const { commitBatchMetaUpdates, pushBatchMetaUpdates } = this.props;
if (!this.props.isDirty) {
this.props.updateWidgetMetaProperty("isDirty", true);
pushBatchMetaUpdates("isDirty", true);
}

this.props.updateWidgetMetaProperty("isChecked", isChecked, {
pushBatchMetaUpdates("isChecked", isChecked, {
triggerPropertyName: "onCheckChange",
dynamicString: this.props.onCheckChange,
event: {
type: EventType.ON_CHECK_CHANGE,
},
});
commitBatchMetaUpdates();
};

getWidgetView() {
Expand Down
28 changes: 14 additions & 14 deletions app/client/src/widgets/wds/WDSInputWidget/widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,19 @@ class WDSInputWidget extends WDSBaseInputWidget<InputWidgetProps, WidgetState> {
};

componentDidUpdate = (prevProps: InputWidgetProps) => {
const { commitBatchMetaUpdates, pushBatchMetaUpdates } = this.props;
if (
prevProps.rawText !== this.props.rawText &&
this.props.rawText !== toString(this.props.parsedText)
) {
this.props.updateWidgetMetaProperty(
pushBatchMetaUpdates(
"parsedText",
parseText(this.props.rawText, this.props.inputType),
);
}

if (prevProps.inputType !== this.props.inputType) {
this.props.updateWidgetMetaProperty(
pushBatchMetaUpdates(
"parsedText",
parseText(this.props.rawText, this.props.inputType),
);
Expand All @@ -173,21 +174,20 @@ class WDSInputWidget extends WDSBaseInputWidget<InputWidgetProps, WidgetState> {
this.props.defaultText !== prevProps.defaultText &&
this.props.isDirty
) {
this.props.updateWidgetMetaProperty("isDirty", false);
pushBatchMetaUpdates("isDirty", false);
}
commitBatchMetaUpdates();
};

onValueChange = (value: string) => {
const { commitBatchMetaUpdates, pushBatchMetaUpdates } = this.props;
// Ideally text property should be derived property. But widgets with
// derived properties won't work as expected inside a List widget.
// TODO(Balaji): Once we refactor the List widget, need to conver
// text to a derived property.
this.props.updateWidgetMetaProperty(
"parsedText",
parseText(value, this.props.inputType),
);
pushBatchMetaUpdates("parsedText", parseText(value, this.props.inputType));

this.props.updateWidgetMetaProperty("rawText", value, {
pushBatchMetaUpdates("rawText", value, {
triggerPropertyName: "onTextChanged",
dynamicString: this.props.onTextChanged,
event: {
Expand All @@ -196,16 +196,16 @@ class WDSInputWidget extends WDSBaseInputWidget<InputWidgetProps, WidgetState> {
});

if (!this.props.isDirty) {
this.props.updateWidgetMetaProperty("isDirty", true);
pushBatchMetaUpdates("isDirty", true);
}
commitBatchMetaUpdates();
};

resetWidgetText = () => {
this.props.updateWidgetMetaProperty("rawText", "");
this.props.updateWidgetMetaProperty(
"parsedText",
parseText("", this.props.inputType),
);
const { commitBatchMetaUpdates, pushBatchMetaUpdates } = this.props;
pushBatchMetaUpdates("rawText", "");
pushBatchMetaUpdates("parsedText", parseText("", this.props.inputType));
commitBatchMetaUpdates();
};

onPaste = (e: React.ClipboardEvent<HTMLInputElement>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,20 @@ class WDSRadioGroupWidget extends BaseWidget<
} else {
newVal = updatedValue;
}
const { commitBatchMetaUpdates, pushBatchMetaUpdates } = this.props;
// Set isDirty to true when the selection changes
if (!this.props.isDirty) {
this.props.updateWidgetMetaProperty("isDirty", true);
pushBatchMetaUpdates("isDirty", true);
}

this.props.updateWidgetMetaProperty("selectedOptionValue", newVal, {
pushBatchMetaUpdates("selectedOptionValue", newVal, {
triggerPropertyName: "onSelectionChange",
dynamicString: this.props.onSelectionChange,
event: {
type: EventType.ON_OPTION_CHANGE,
},
});
commitBatchMetaUpdates();
};

getWidgetView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,19 @@ class WDSSwitchGroupWidget extends BaseWidget<
}

onChange = (selectedValues: OptionProps["value"][]) => {
const { commitBatchMetaUpdates, pushBatchMetaUpdates } = this.props;
if (!this.props.isDirty) {
this.props.updateWidgetMetaProperty("isDirty", true);
pushBatchMetaUpdates("isDirty", true);
}

this.props.updateWidgetMetaProperty("selectedValues", selectedValues, {
pushBatchMetaUpdates("selectedValues", selectedValues, {
triggerPropertyName: "onSelectionChange",
dynamicString: this.props.onSelectionChange,
event: {
type: EventType.ON_SWITCH_GROUP_SELECTION_CHANGE,
},
});
commitBatchMetaUpdates();
};

getWidgetView() {
Expand Down
6 changes: 4 additions & 2 deletions app/client/src/widgets/wds/WDSSwitchWidget/widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,19 @@ class WDSSwitchWidget extends BaseWidget<SwitchWidgetProps, WidgetState> {
}

onChange = (isSwitchedOn: boolean) => {
const { commitBatchMetaUpdates, pushBatchMetaUpdates } = this.props;
if (!this.props.isDirty) {
this.props.updateWidgetMetaProperty("isDirty", true);
pushBatchMetaUpdates("isDirty", true);
}

this.props.updateWidgetMetaProperty("isSwitchedOn", isSwitchedOn, {
pushBatchMetaUpdates("isSwitchedOn", isSwitchedOn, {
triggerPropertyName: "onChange",
dynamicString: this.props.onChange,
event: {
type: EventType.ON_SWITCH_CHANGE,
},
});
commitBatchMetaUpdates();
};

getWidgetView() {
Expand Down