Skip to content
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

fix(color-dialog): can not change value between default color and black color #557

Merged
merged 2 commits into from
Dec 23, 2022
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 @@ -224,6 +224,12 @@ describe('color-dialog/ColorDialog', () => {
await elementUpdated();
expect(confirmBtn.disabled).to.equal(false);
});
it('should enabled confirmed button when change from default color to black color', async () => {
hexInput.value = '000000';
hexInput.dispatchEvent(new Event('value-changed'));
await elementUpdated();
expect(confirmBtn.disabled).to.equal(false);
});
it('should enabled confirmed button when r,g,b is valid', async () => {
redInput.value = '255';
greenInput.value = '200';
Expand Down
4 changes: 3 additions & 1 deletion packages/elements/src/color-dialog/helpers/value-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ class ValueModel {
* @returns true if different
*/
public hasChanged (): boolean {
return rgb(this.initialValue).formatHex() !== rgb(this.value).formatHex();
// Avoid the same hex color format of empty string and black color
return ((this.initialValue !== this.value) && ((!!this.initialValue && !!this.value) === false))
|| rgb(this.initialValue).formatHex() !== rgb(this.value).formatHex();
}

/**
Expand Down