Skip to content

Fix completed html strings and styles #9997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions e2e/survey/cookie.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ frameworks.forEach((framework) => {
await page.goto(`${url}${framework}`);
await initSurvey(page, framework, json);

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

await expect(page.locator(".sd-body h3").getByText("You have already completed this survey.")).not.toBeVisible();
await expect(page.locator(".sd-body").getByText("You have already completed this survey.")).not.toBeVisible();
});
});
});
29 changes: 15 additions & 14 deletions packages/survey-core/src/default-theme/blocks/sd-completedpage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@use "../mixins.scss" as mixins;

.sd-completedpage,
.sd-body--loading,
.sd-completed-before-page {
align-items: center;
font-family: $font-family;
Expand All @@ -10,20 +11,20 @@
text-align: center;
height: auto;
@include mixins.articleHtml;
&:not(:has(> *)) {
@include mixins.articleLargeFont;
}
}

.sd-completedpage:before,
.sd-completedpage:after {
display: block;
width: calcSize(9);
margin-left: calc(50% - 4.5 * #{$base-unit});
content: "";
.sd-completedpage {
&:has(> *) {
padding: calcSize(13) 0 calcSize(2) 0;
}
padding: calcSize(17) 0 calcSize(6) 0;
}

.sd-completedpage:before {
height: calcSize(13);
.sd-body--loading,
.sd-completed-before-page {
&:has(> *) {
padding: 0;
}
padding: calcSize(4) 0 calcSize(4) 0;
}

.sd-completedpage:after {
height: calcSize(2);
}
9 changes: 6 additions & 3 deletions packages/survey-core/src/default-theme/mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
h2 {
@include articleXLargeFont;
}

h3 {
@include articleLargeFont;
}
Expand Down Expand Up @@ -144,15 +143,19 @@
font-size: $font-questiontitle-size;
line-height: multiply(1.5, $font-questiontitle-size);

box-shadow: $shadow-small, 0 0 0 0px $primary;
box-shadow:
$shadow-small,
0 0 0 0px $primary;
transition: box-shadow $transition-duration;

&:hover {
background-color: $background-dark;
}

&:focus {
box-shadow: $shadow-small-reset, 0 0 0 2px $primary;
box-shadow:
$shadow-small-reset,
0 0 0 2px $primary;
}

span {
Expand Down
4 changes: 0 additions & 4 deletions packages/survey-core/src/localizablestring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export class LocalizableString implements ILocalizableString {
public onGetTextCallback: (str: string, nonProcessedText?: string) => string;
public storeDefaultText: boolean;
public serializeCallBackText: boolean;
public onGetLocalizationTextCallback: (str: string) => string;
public onStrChanged: (oldValue: string, newValue: string) => void;
public lastChangedLoc: string;
public onSearchChanged: () => void;
Expand Down Expand Up @@ -155,9 +154,6 @@ export class LocalizableString implements ILocalizableString {
}
if (this.isValueEmpty(res) && !!this.getLocalizationName()) {
res = this.getLocalizationStr();
if (!!this.onGetLocalizationTextCallback) {
res = this.onGetLocalizationTextCallback(res);
}
}
if (!res) res = this.defaultValue || "";
return res;
Expand Down
13 changes: 4 additions & 9 deletions packages/survey-core/src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -950,10 +950,9 @@ export class SurveyModel extends SurveyElementCore
// if (DomDocumentHelper.isAvailable()) {
// SurveyModel.stylesManager = new StylesManager();
// }
const htmlCallBack = (str: string): string => { return "<h3>" + str + "</h3>"; };
this.createHtmlLocString("completedHtml", "completingSurvey", htmlCallBack);
this.createHtmlLocString("completedBeforeHtml", "completingSurveyBefore", htmlCallBack, "completed-before");
this.createHtmlLocString("loadingHtml", "loadingSurvey", htmlCallBack, "loading");
this.createHtmlLocString("completedHtml", "completingSurvey");
this.createHtmlLocString("completedBeforeHtml", "completingSurveyBefore", "completed-before");
this.createHtmlLocString("loadingHtml", "loadingSurvey", "loading");
this.createLocalizableString("emptySurveyText", this, true, "emptySurvey");
this.createLocalizableString("logo", this, false);
this.createLocalizableString("startSurveyText", this, false, true);
Expand Down Expand Up @@ -1170,9 +1169,8 @@ export class SurveyModel extends SurveyElementCore
}
};
}
private createHtmlLocString(name: string, locName: string, func: (str: string) => string, reason?: string): void {
private createHtmlLocString(name: string, locName: string, reason?: string): void {
const res = this.createLocalizableString(name, this, false, locName);
res.onGetLocalizationTextCallback = func;
if (reason) {
res.onGetTextCallback = (str: string): string => { return this.processHtml(str, reason); };
}
Expand Down Expand Up @@ -2614,9 +2612,6 @@ export class SurveyModel extends SurveyElementCore
get locLoadingHtml(): LocalizableString {
return this.getLocalizableString("loadingHtml");
}
public get defaultLoadingHtml(): string {
return "<h3>" + this.getLocalizationString("loadingSurvey") + "</h3>";
}
public get navigationBar(): ActionContainer {
if (!this.navigationBarValue) {
this.navigationBarValue = this.createNavigationBar();
Expand Down
8 changes: 0 additions & 8 deletions packages/survey-core/tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3506,14 +3506,6 @@ QUnit.test("pre process title, 'locale' variable", function (assert) {
);
});

QUnit.test("Default value completedHtml, completedBeforeHtml and loadingHtml", function (assert) {
const survey = new SurveyModel();
survey.locale = "";
assert.ok(survey.completedHtml.indexOf("</h3>") > -1, "h3 is here, default completedHtml");
assert.ok(survey.completedBeforeHtml.indexOf("</h3>") > -1, "h3 is here, default completedBeforeHtml");
assert.ok(survey.loadingHtml.indexOf("</h3>") > -1, "h3 is here, default loadingHtml");
});

QUnit.test(
"pre process title with variables in Capital letters, bug#1099",
function (assert) {
Expand Down