Skip to content

Commit 7839f6e

Browse files
authored
Fix completed html strings and styles (#9997)
* Fix completed html strings and styles * Fix scr tests * Fix scr tests * Fix e2e test * Fix scr tests
1 parent 748a45c commit 7839f6e

File tree

6 files changed

+27
-40
lines changed

6 files changed

+27
-40
lines changed

e2e/survey/cookie.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ frameworks.forEach((framework) => {
4949
await page.goto(`${url}${framework}`);
5050
await initSurvey(page, framework, json);
5151

52-
await expect(page.locator(".sd-body h3").getByText("You have already completed this survey.")).toBeVisible();
52+
await expect(page.locator(".sd-body").getByText("You have already completed this survey.")).toBeVisible();
5353
await deleteCookie(page);
5454
await firstElement.hover();
5555

56-
await expect(page.locator(".sd-body h3").getByText("You have already completed this survey.")).not.toBeVisible();
56+
await expect(page.locator(".sd-body").getByText("You have already completed this survey.")).not.toBeVisible();
5757
});
5858
});
5959
});

packages/survey-core/src/default-theme/blocks/sd-completedpage.scss

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@use "../mixins.scss" as mixins;
33

44
.sd-completedpage,
5+
.sd-body--loading,
56
.sd-completed-before-page {
67
align-items: center;
78
font-family: $font-family;
@@ -10,20 +11,20 @@
1011
text-align: center;
1112
height: auto;
1213
@include mixins.articleHtml;
14+
&:not(:has(> *)) {
15+
@include mixins.articleLargeFont;
16+
}
1317
}
14-
15-
.sd-completedpage:before,
16-
.sd-completedpage:after {
17-
display: block;
18-
width: calcSize(9);
19-
margin-left: calc(50% - 4.5 * #{$base-unit});
20-
content: "";
18+
.sd-completedpage {
19+
&:has(> *) {
20+
padding: calcSize(13) 0 calcSize(2) 0;
21+
}
22+
padding: calcSize(17) 0 calcSize(6) 0;
2123
}
22-
23-
.sd-completedpage:before {
24-
height: calcSize(13);
24+
.sd-body--loading,
25+
.sd-completed-before-page {
26+
&:has(> *) {
27+
padding: 0;
28+
}
29+
padding: calcSize(4) 0 calcSize(4) 0;
2530
}
26-
27-
.sd-completedpage:after {
28-
height: calcSize(2);
29-
}

packages/survey-core/src/default-theme/mixins.scss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@
102102
h2 {
103103
@include articleXLargeFont;
104104
}
105-
106105
h3 {
107106
@include articleLargeFont;
108107
}
@@ -144,15 +143,19 @@
144143
font-size: $font-questiontitle-size;
145144
line-height: multiply(1.5, $font-questiontitle-size);
146145

147-
box-shadow: $shadow-small, 0 0 0 0px $primary;
146+
box-shadow:
147+
$shadow-small,
148+
0 0 0 0px $primary;
148149
transition: box-shadow $transition-duration;
149150

150151
&:hover {
151152
background-color: $background-dark;
152153
}
153154

154155
&:focus {
155-
box-shadow: $shadow-small-reset, 0 0 0 2px $primary;
156+
box-shadow:
157+
$shadow-small-reset,
158+
0 0 0 2px $primary;
156159
}
157160

158161
span {

packages/survey-core/src/localizablestring.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export class LocalizableString implements ILocalizableString {
6161
public onGetTextCallback: (str: string, nonProcessedText?: string) => string;
6262
public storeDefaultText: boolean;
6363
public serializeCallBackText: boolean;
64-
public onGetLocalizationTextCallback: (str: string) => string;
6564
public onStrChanged: (oldValue: string, newValue: string) => void;
6665
public lastChangedLoc: string;
6766
public onSearchChanged: () => void;
@@ -155,9 +154,6 @@ export class LocalizableString implements ILocalizableString {
155154
}
156155
if (this.isValueEmpty(res) && !!this.getLocalizationName()) {
157156
res = this.getLocalizationStr();
158-
if (!!this.onGetLocalizationTextCallback) {
159-
res = this.onGetLocalizationTextCallback(res);
160-
}
161157
}
162158
if (!res) res = this.defaultValue || "";
163159
return res;

packages/survey-core/src/survey.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -950,10 +950,9 @@ export class SurveyModel extends SurveyElementCore
950950
// if (DomDocumentHelper.isAvailable()) {
951951
// SurveyModel.stylesManager = new StylesManager();
952952
// }
953-
const htmlCallBack = (str: string): string => { return "<h3>" + str + "</h3>"; };
954-
this.createHtmlLocString("completedHtml", "completingSurvey", htmlCallBack);
955-
this.createHtmlLocString("completedBeforeHtml", "completingSurveyBefore", htmlCallBack, "completed-before");
956-
this.createHtmlLocString("loadingHtml", "loadingSurvey", htmlCallBack, "loading");
953+
this.createHtmlLocString("completedHtml", "completingSurvey");
954+
this.createHtmlLocString("completedBeforeHtml", "completingSurveyBefore", "completed-before");
955+
this.createHtmlLocString("loadingHtml", "loadingSurvey", "loading");
957956
this.createLocalizableString("emptySurveyText", this, true, "emptySurvey");
958957
this.createLocalizableString("logo", this, false);
959958
this.createLocalizableString("startSurveyText", this, false, true);
@@ -1170,9 +1169,8 @@ export class SurveyModel extends SurveyElementCore
11701169
}
11711170
};
11721171
}
1173-
private createHtmlLocString(name: string, locName: string, func: (str: string) => string, reason?: string): void {
1172+
private createHtmlLocString(name: string, locName: string, reason?: string): void {
11741173
const res = this.createLocalizableString(name, this, false, locName);
1175-
res.onGetLocalizationTextCallback = func;
11761174
if (reason) {
11771175
res.onGetTextCallback = (str: string): string => { return this.processHtml(str, reason); };
11781176
}
@@ -2614,9 +2612,6 @@ export class SurveyModel extends SurveyElementCore
26142612
get locLoadingHtml(): LocalizableString {
26152613
return this.getLocalizableString("loadingHtml");
26162614
}
2617-
public get defaultLoadingHtml(): string {
2618-
return "<h3>" + this.getLocalizationString("loadingSurvey") + "</h3>";
2619-
}
26202615
public get navigationBar(): ActionContainer {
26212616
if (!this.navigationBarValue) {
26222617
this.navigationBarValue = this.createNavigationBar();

packages/survey-core/tests/surveytests.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3506,14 +3506,6 @@ QUnit.test("pre process title, 'locale' variable", function (assert) {
35063506
);
35073507
});
35083508

3509-
QUnit.test("Default value completedHtml, completedBeforeHtml and loadingHtml", function (assert) {
3510-
const survey = new SurveyModel();
3511-
survey.locale = "";
3512-
assert.ok(survey.completedHtml.indexOf("</h3>") > -1, "h3 is here, default completedHtml");
3513-
assert.ok(survey.completedBeforeHtml.indexOf("</h3>") > -1, "h3 is here, default completedBeforeHtml");
3514-
assert.ok(survey.loadingHtml.indexOf("</h3>") > -1, "h3 is here, default loadingHtml");
3515-
});
3516-
35173509
QUnit.test(
35183510
"pre process title with variables in Capital letters, bug#1099",
35193511
function (assert) {

0 commit comments

Comments
 (0)