Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functional test on entering empty space #6679
Browse files Browse the repository at this point in the history
andrewtelnov committed Aug 9, 2023
1 parent d8c60ca commit 43e8844
Showing 10 changed files with 36 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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, false, true)) {
if (!Helpers.isTwoValueEquals(newValue, control.value, false, true, false)) {
control.value = this.model.inputStringRendered || "";
}
}
4 changes: 3 additions & 1 deletion packages/survey-vue3-ui/src/components/dropdown/Dropdown.vue
Original file line number Diff line number Diff line change
@@ -144,7 +144,9 @@ const updateInputDomElement = () => {
if (inputElement.value) {
const control: any = inputElement.value;
const newValue = model.value.inputStringRendered;
if (!Helpers.isTwoValueEquals(newValue, control.value)) {
if (
!Helpers.isTwoValueEquals(newValue, control.value, false, true, false)
) {
control.value = model.value.inputStringRendered;
}
}
2 changes: 1 addition & 1 deletion src/calculatedValue.ts
Original file line number Diff line number Diff line change
@@ -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, false, true)) {
if (!Helpers.isTwoValueEquals(newValue, this.value, false, true, false)) {
this.setValue(newValue);
}
this.unlocCalculation();
2 changes: 1 addition & 1 deletion src/question_file.ts
Original file line number Diff line number Diff line change
@@ -280,7 +280,7 @@ export class QuestionFileModel extends Question {
if (status === "success") {
var oldValue = this.value;
if (Array.isArray(oldValue)) {
this.value = oldValue.filter((f) => !Helpers.isTwoValueEquals(f, content, true));
this.value = oldValue.filter((f) => !Helpers.isTwoValueEquals(f, content, true, false, false));
} else {
this.value = undefined;
}
2 changes: 1 addition & 1 deletion src/question_paneldynamic.ts
Original file line number Diff line number Diff line change
@@ -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, false, true)) return;
if (Helpers.isTwoValueEquals(newValue, oldValue, false, true, false)) return;
this.data.setPanelItemData(this, name, Helpers.getUnbindValue(newValue));
const questions = this.panel.questions;
for (var i = 0; i < questions.length; i++) {
2 changes: 1 addition & 1 deletion src/react/dropdown-base.tsx
Original file line number Diff line number Diff line change
@@ -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, false, true)) {
if (!Helpers.isTwoValueEquals(newValue, control.value, false, true, false)) {
control.value = this.question.dropdownListModel.inputStringRendered;
}
}
4 changes: 2 additions & 2 deletions src/react/reactquestion_element.tsx
Original file line number Diff line number Diff line change
@@ -282,7 +282,7 @@ export class SurveyQuestionUncontrolledElement<
}
updateValueOnEvent = (event: any) => {
if (
!Helpers.isTwoValueEquals(this.questionBase.value, event.target.value, false, true)
!Helpers.isTwoValueEquals(this.questionBase.value, event.target.value, false, true, false)
) {
this.setValueCore(event.target.value);
}
@@ -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, false, true)) {
if (!Helpers.isTwoValueEquals(newValue, control.value, false, true, false)) {
control.value = this.getValue(newValue);
}
}
2 changes: 1 addition & 1 deletion src/react/tagbox-filter.tsx
Original file line number Diff line number Diff line change
@@ -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, false, true)) {
if (!Helpers.isTwoValueEquals(newValue, control.value, false, true, false)) {
control.value = this.model.inputStringRendered;
}
}
2 changes: 1 addition & 1 deletion src/vue/components/dropdown/dropdown.vue
Original file line number Diff line number Diff line change
@@ -152,7 +152,7 @@ export class DropdownComponent extends BaseVue {
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, false)) {
control.value = this.model.inputStringRendered;
}
}
24 changes: 24 additions & 0 deletions testCafe/questions/text.js
Original file line number Diff line number Diff line change
@@ -219,4 +219,28 @@ frameworks.forEach((framework) => {
.pressKey("backspace")
.expect(characterCounter.textContent).eql("0/10");
});
test.only("Remaining character counter", async (t) => {
const characterCounter = Selector(".sv-remaining-character-counter");

await initSurvey(framework, {
questions: [
{
name: "name",
type: "text",
maxLength: 10,
}]
});
await ClientFunction(() => {
window.survey.getQuestionByName("name").allowSpaceAsAnswer = true;
})();

await t
.pressKey("space")
.click("input[value=Complete]");

const surveyResult = await getSurveyResult();
await t.expect(surveyResult).eql({
name: " ",
});
});
});

0 comments on commit 43e8844

Please sign in to comment.