Skip to content

Fix warnings: fix color input's empty value. #6670

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 1 commit into from
Feb 28, 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
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class QuestionColorModel extends QuestionTextModel {
return { backgroundColor: this.renderedValue };
}
public get renderedColorValue() {
return this.renderedValue;
return this.renderedValue || DEFAULT_COLOR;
}
public get isInputTextUpdate(): boolean {
return false;
Expand Down
18 changes: 9 additions & 9 deletions packages/survey-creator-core/tests/property-grid/color.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,20 @@ test("Check custom color question with allowEmptyValue:true", () => {
const question = new QuestionColorModel("q1");
question.allowEmptyValue = true;
expect(question.renderedValue).toBe("");
expect(question.renderedColorValue).toBe("");
expect(question.renderedColorValue).toBe("#000000");
expect(question.value).toBe(undefined);
question.value = undefined;
expect(question.value).toBe(undefined);
expect(question.renderedValue).toBe("");
expect(question.renderedColorValue).toBe("");
expect(question.renderedColorValue).toBe("#000000");
question.value = null;
expect(question.value).toBe(undefined);
expect(question.renderedValue).toBe("");
expect(question.renderedColorValue).toBe("");
expect(question.renderedColorValue).toBe("#000000");
question.value = "";
expect(question.value).toBe(undefined);
expect(question.renderedValue).toBe("");
expect(question.renderedColorValue).toBe("");
expect(question.renderedColorValue).toBe("#000000");
});
test("Check custom color question event callbacks", () => {
const question = new QuestionColorModel("q1");
Expand Down Expand Up @@ -172,7 +172,7 @@ test("QuestionColorModel renderedValue always HEX (value from survey)", () => {
test("QuestionColorModel renderedValue when _renderedValue and value are empty", () => {
let q = new QuestionColorModel("q1");
q._renderedValue = "";
expect(q.renderedColorValue).toBe("");
expect(q.renderedColorValue).toBe("#000000");
q = new QuestionColorModel("q1");
q._renderedValue = "";
q.value = "";
Expand All @@ -188,8 +188,8 @@ test("Check signature pad color properties", () => {
expect(backgroundColorQuestion.getType()).toBe("color");
expect(penColorQuestion.renderedValue).toBe("");
expect(backgroundColorQuestion.renderedValue).toBe("");
expect(penColorQuestion.renderedColorValue).toBe("");
expect(backgroundColorQuestion.renderedColorValue).toBe("");
expect(penColorQuestion.renderedColorValue).toBe("#000000");
expect(backgroundColorQuestion.renderedColorValue).toBe("#000000");
question.penColor = "#f3f3f3";
expect(penColorQuestion.renderedValue).toBe("#F3F3F3");
expect(penColorQuestion.renderedColorValue).toBe("#F3F3F3");
Expand All @@ -209,8 +209,8 @@ test("Check signature pad color properties", () => {
expect(backgroundColorQuestion.allowEmptyValue).toBeTruthy();
expect(penColorQuestion.renderedValue).toBe("");
expect(backgroundColorQuestion.renderedValue).toBe("");
expect(penColorQuestion.renderedColorValue).toBe("");
expect(backgroundColorQuestion.renderedColorValue).toBe("");
expect(penColorQuestion.renderedColorValue).toBe("#000000");
expect(backgroundColorQuestion.renderedColorValue).toBe("#000000");
question.penColor = "#f3f3f3";
expect(penColorQuestion.renderedValue).toBe("#F3F3F3");
expect(penColorQuestion.renderedColorValue).toBe("#F3F3F3");
Expand Down