Skip to content

Commit

Permalink
Features/6679 allow enter empty space (#6687)
Browse files Browse the repository at this point in the history
* Add functional test on entering empty space #6679

* Remove test.only #6679

* Rename the functional test #6679
  • Loading branch information
andrewtelnov committed Aug 10, 2023
1 parent e3964b0 commit 31b1a7e
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 10 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, false, true)) {
if (!Helpers.isTwoValueEquals(newValue, control.value, false, true, false)) {
control.value = this.model.inputStringRendered || "";
}
}
Expand Down
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
Expand Up @@ -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;
}
}
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, false, true)) {
if (!Helpers.isTwoValueEquals(newValue, this.value, false, true, false)) {
this.setValue(newValue);
}
this.unlocCalculation();
Expand Down
2 changes: 1 addition & 1 deletion src/question_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,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;
}
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, 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++) {
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, false, true)) {
if (!Helpers.isTwoValueEquals(newValue, control.value, false, true, false)) {
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, false, true)
!Helpers.isTwoValueEquals(this.questionBase.value, event.target.value, false, true, false)
) {
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, false, true)) {
if (!Helpers.isTwoValueEquals(newValue, control.value, false, true, false)) {
control.value = this.getValue(newValue);
}
}
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, false, true)) {
if (!Helpers.isTwoValueEquals(newValue, control.value, false, true, false)) {
control.value = this.model.inputStringRendered;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/vue/components/dropdown/dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
22 changes: 22 additions & 0 deletions testCafe/questions/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,26 @@ frameworks.forEach((framework) => {
.pressKey("backspace")
.expect(characterCounter.textContent).eql("0/10");
});
test("Allow Space As Answer", async (t) => {
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 31b1a7e

Please sign in to comment.