Skip to content

Commit

Permalink
ColorPicker: fix default null color
Browse files Browse the repository at this point in the history
  • Loading branch information
stsrki committed Dec 18, 2024
1 parent 922e05d commit 71b0506
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Source/Blazorise/wwwroot/colorPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ export function initialize(dotnetAdapter, element, elementId, options) {
if (!element)
return;

const noDefault = !options.default;

const picker = Pickr.create({
el: element,
theme: 'monolith', // 'monolith' or 'nano'

useAsButton: element,

comparison: false,
default: options.default || "#000000",
default: options.default || "#00000000",
position: 'bottom-start',
silent: true,

Expand Down Expand Up @@ -65,7 +67,16 @@ export function initialize(dotnetAdapter, element, elementId, options) {
}
});

const hexColor = options.default ? options.default : "#000000";
if (noDefault) {
const resetColor = () => {
picker.setColor(null);
picker.off('init', resetColor);
};

picker.on('init', resetColor);
}

const hexColor = options.default ? options.default : "#00000000";

const colorPreviewElement = element.querySelector(options.colorPreviewElementSelector || ":scope > .b-input-color-picker-preview > .b-input-color-picker-curent-color");
const colorValueElement = element.querySelector(options.colorValueElementSelector || ":scope > .b-input-color-picker-preview > .b-input-color-picker-curent-value");
Expand Down

0 comments on commit 71b0506

Please sign in to comment.