Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dk981234 committed Aug 10, 2023
2 parents 35a3dc2 + 62ad180 commit c0303ec
Show file tree
Hide file tree
Showing 13 changed files with 83 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
4 changes: 4 additions & 0 deletions src/defaultV2-theme/blocks/sd-row.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
margin-top: calcSize(2);
}

.sd-page__row.sd-row--compact {
margin-top: var(--sd-base-vertical-padding);
}

.sd-row:first-of-type {
margin-top: 0;
}
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: " ",
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions visualRegressionTests/tests/defaultV2/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,51 @@ frameworks.forEach(framework => {
await t.resizeWindow(1920, 1080);
});
});
test("Check survey in compact mode", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await t.resizeWindow(1920, 1080);
const json = {
title: "Lightweight",
widthMode: "static",
showQuestionNumbers: "off",
width: "1000px",
pages: [{
elements: [
{
name: "q1",
title: "First Name",
type: "text"
},
{
name: "q2",
title: "Last Name",
startWithNewLine: false,
type: "text"
},
{
name: "q3",
title: "Middle Name",
startWithNewLine: false,
type: "text"
},
{
name: "q4",
title: "Address",
type: "comment"
}
]
}
]
};
await initSurvey(framework, json);
await resetFocusToBody();
await ClientFunction(() => {
document.body.style.setProperty("--background-dim", "#fff");
(<any>window).survey.isCompact = true;
})();
await takeElementScreenshot("survey-page-without-title-compact.png", Selector(".sd-root-modern"), t, comparer);
});
});
test("Check survey in compact mode", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await t.resizeWindow(1920, 1080);
Expand Down

0 comments on commit c0303ec

Please sign in to comment.