Skip to content

Commit

Permalink
React: survey.onValueChanging do not allow to change value into Upper…
Browse files Browse the repository at this point in the history
…Case fix #6519 (#6520)
  • Loading branch information
andrewtelnov committed Jul 13, 2023
1 parent 00607bc commit baccf8d
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class DropdownComponent extends BaseAngular implements OnInit {
if (!!this.inputElementRef?.nativeElement) {
const control: any = this.inputElementRef.nativeElement;
const newValue = this.model.inputStringRendered;
if (!Helpers.isTwoValueEquals(newValue, control.value)) {
if (!Helpers.isTwoValueEquals(newValue, control.value, false, true)) {
control.value = this.model.inputStringRendered || "";
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/calculatedValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class CalculatedValue extends Base {
if (!!this.expressionRunner) return;
this.expressionRunner = new ExpressionRunner(this.expression);
this.expressionRunner.onRunComplete = newValue => {
if (!Helpers.isTwoValueEquals(newValue, this.value)) {
if (!Helpers.isTwoValueEquals(newValue, this.value, false, true)) {
this.setValue(newValue);
}
this.unlocCalculation();
Expand Down
4 changes: 2 additions & 2 deletions src/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ export class Question extends SurveyElement<Question>
this.defaultValueRunner,
this.getUnbindValue(this.defaultValue),
(val) => {
if(!Helpers.isTwoValueEquals(this.value, val)) {
if(!this.isTwoValueEquals(this.value, val)) {
this.value = val;
}
}
Expand Down Expand Up @@ -1627,7 +1627,7 @@ export class Question extends SurveyElement<Question>
if (!setFunc) {
setFunc = (val: any): void => {
this.runExpressionSetValue(val, (val: any): void => {
if(!Helpers.isTwoValueEquals(this.value, val)) {
if(!this.isTwoValueEquals(this.value, val)) {
this.value = val;
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/question_paneldynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class QuestionPanelDynamicItem implements ISurveyData, ISurveyImpl {
public setValue(name: string, newValue: any) {
const oldItemData = this.data.getPanelItemData(this);
const oldValue = !!oldItemData ? oldItemData[name] : undefined;
if (Helpers.isTwoValueEquals(newValue, oldValue)) return;
if (Helpers.isTwoValueEquals(newValue, oldValue, false, true)) return;
this.data.setPanelItemData(this, name, Helpers.getUnbindValue(newValue));
const questions = this.panel.questions;
for (var i = 0; i < questions.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/question_text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export class QuestionTextModel extends QuestionTextBase {
private _isWaitingForEnter = false;
private updateValueOnEvent(event: any) {
const newValue = event.target.value;
if (!Helpers.isTwoValueEquals(this.value, newValue)) {
if (!this.isTwoValueEquals(this.value, newValue)) {
this.value = newValue;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/react/dropdown-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class SurveyQuestionDropdownBase<T extends Question> extends SurveyQuesti
if (!!this.inputElement) {
const control: any = this.inputElement;
const newValue = this.question.dropdownListModel.inputStringRendered;
if (!Helpers.isTwoValueEquals(newValue, control.value)) {
if (!Helpers.isTwoValueEquals(newValue, control.value, false, true)) {
control.value = this.question.dropdownListModel.inputStringRendered;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/react/reactquestion_element.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export class SurveyQuestionUncontrolledElement<
}
updateValueOnEvent = (event: any) => {
if (
!Helpers.isTwoValueEquals(this.questionBase.value, event.target.value)
!Helpers.isTwoValueEquals(this.questionBase.value, event.target.value, false, true)
) {
this.setValueCore(event.target.value);
}
Expand All @@ -297,7 +297,7 @@ export class SurveyQuestionUncontrolledElement<
if (!!this.control) {
const control: any = this.control;
const newValue = this.getValueCore();
if (!Helpers.isTwoValueEquals(newValue, control.value)) {
if (!Helpers.isTwoValueEquals(newValue, control.value, false, true)) {
control.value = this.getValue(newValue);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/react/reactquestion_matrix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ export class SurveyQuestionMatrixRow extends ReactSurveyElement {
var column = this.question.visibleColumns[i];
var key = "value" + i;

//var isChecked = Helpers.isTwoValueEquals(row.value, column.value);
var isChecked = row.value == column.value;
let itemClass = this.question.getItemClass(row, column);
var inputId = this.question.inputId + "_" + row.name + "_" + i;
Expand Down
2 changes: 1 addition & 1 deletion src/react/tagbox-filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class TagboxFilterString extends SurveyElementBase<ITagboxFilterProps, an
if (!!this.inputElement) {
const control: any = this.inputElement;
const newValue = this.model.inputStringRendered;
if (!Helpers.isTwoValueEquals(newValue, control.value)) {
if (!Helpers.isTwoValueEquals(newValue, control.value, false, true)) {
control.value = this.model.inputStringRendered;
}
}
Expand Down
11 changes: 10 additions & 1 deletion tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17264,4 +17264,13 @@ QUnit.test("Check onPopupVisibleChanged events", function (assert) {
popup.toggleVisibility();
assert.equal(log, "->true->false");
});

QUnit.test("Check onPopupVisibleChanged events", function (assert) {
assert.equal(settings.comparator.caseSensitive, false, "comparator.caseSensitive is false");
const survey = new SurveyModel({ elements: [{ "type": "text", "name": "q1" }] });
const q = survey.getQuestionByName("q1");
survey.onValueChanging.add((sender, options) => {
options.value = options.value.toUpperCase();
});
q.value = "abc";
assert.equal(q.value, "ABC", "Convert to upper case");
});

0 comments on commit baccf8d

Please sign in to comment.