Skip to content

Commit 50ffb4c

Browse files
authored
Fix warnings: fix color input's empty value. (#6670)
1 parent c4f40b0 commit 50ffb4c

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

packages/survey-creator-core/src/custom-questions/question-color.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class QuestionColorModel extends QuestionTextModel {
8686
return { backgroundColor: this.renderedValue };
8787
}
8888
public get renderedColorValue() {
89-
return this.renderedValue;
89+
return this.renderedValue || DEFAULT_COLOR;
9090
}
9191
public get isInputTextUpdate(): boolean {
9292
return false;

packages/survey-creator-core/tests/property-grid/color.tests.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,20 @@ test("Check custom color question with allowEmptyValue:true", () => {
5858
const question = new QuestionColorModel("q1");
5959
question.allowEmptyValue = true;
6060
expect(question.renderedValue).toBe("");
61-
expect(question.renderedColorValue).toBe("");
61+
expect(question.renderedColorValue).toBe("#000000");
6262
expect(question.value).toBe(undefined);
6363
question.value = undefined;
6464
expect(question.value).toBe(undefined);
6565
expect(question.renderedValue).toBe("");
66-
expect(question.renderedColorValue).toBe("");
66+
expect(question.renderedColorValue).toBe("#000000");
6767
question.value = null;
6868
expect(question.value).toBe(undefined);
6969
expect(question.renderedValue).toBe("");
70-
expect(question.renderedColorValue).toBe("");
70+
expect(question.renderedColorValue).toBe("#000000");
7171
question.value = "";
7272
expect(question.value).toBe(undefined);
7373
expect(question.renderedValue).toBe("");
74-
expect(question.renderedColorValue).toBe("");
74+
expect(question.renderedColorValue).toBe("#000000");
7575
});
7676
test("Check custom color question event callbacks", () => {
7777
const question = new QuestionColorModel("q1");
@@ -172,7 +172,7 @@ test("QuestionColorModel renderedValue always HEX (value from survey)", () => {
172172
test("QuestionColorModel renderedValue when _renderedValue and value are empty", () => {
173173
let q = new QuestionColorModel("q1");
174174
q._renderedValue = "";
175-
expect(q.renderedColorValue).toBe("");
175+
expect(q.renderedColorValue).toBe("#000000");
176176
q = new QuestionColorModel("q1");
177177
q._renderedValue = "";
178178
q.value = "";
@@ -188,8 +188,8 @@ test("Check signature pad color properties", () => {
188188
expect(backgroundColorQuestion.getType()).toBe("color");
189189
expect(penColorQuestion.renderedValue).toBe("");
190190
expect(backgroundColorQuestion.renderedValue).toBe("");
191-
expect(penColorQuestion.renderedColorValue).toBe("");
192-
expect(backgroundColorQuestion.renderedColorValue).toBe("");
191+
expect(penColorQuestion.renderedColorValue).toBe("#000000");
192+
expect(backgroundColorQuestion.renderedColorValue).toBe("#000000");
193193
question.penColor = "#f3f3f3";
194194
expect(penColorQuestion.renderedValue).toBe("#F3F3F3");
195195
expect(penColorQuestion.renderedColorValue).toBe("#F3F3F3");
@@ -209,8 +209,8 @@ test("Check signature pad color properties", () => {
209209
expect(backgroundColorQuestion.allowEmptyValue).toBeTruthy();
210210
expect(penColorQuestion.renderedValue).toBe("");
211211
expect(backgroundColorQuestion.renderedValue).toBe("");
212-
expect(penColorQuestion.renderedColorValue).toBe("");
213-
expect(backgroundColorQuestion.renderedColorValue).toBe("");
212+
expect(penColorQuestion.renderedColorValue).toBe("#000000");
213+
expect(backgroundColorQuestion.renderedColorValue).toBe("#000000");
214214
question.penColor = "#f3f3f3";
215215
expect(penColorQuestion.renderedValue).toBe("#F3F3F3");
216216
expect(penColorQuestion.renderedColorValue).toBe("#F3F3F3");

0 commit comments

Comments
 (0)