Skip to content
Merged
Changes from 1 commit
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 @@ -20,6 +20,7 @@ export class UmbPropertyEditorUIColorPickerElement
@property({ type: Object })
public override set value(value: UmbSwatchDetails | undefined) {
super.value = value ? this.#ensureHashPrefix(value) : undefined;
this.#syncLabelFromSwatches();
}
public override get value(): UmbSwatchDetails | undefined {
return super.value;
Expand Down Expand Up @@ -49,6 +50,16 @@ export class UmbPropertyEditorUIColorPickerElement

const swatches = config?.getValueByAlias<Array<UmbSwatchDetails>>('items') ?? [];
this._swatches = swatches.map((swatch) => this.#ensureHashPrefix(swatch));
this.#syncLabelFromSwatches();
}

#syncLabelFromSwatches() {
if (!this.value || this._swatches.length === 0) return;
const match = this._swatches.find((swatch) => swatch.value === this.value!.value);
if (match && match.label !== this.value.label) {
super.value = match;
this.dispatchEvent(new UmbChangeEvent());
}
Comment thread
AndyButland marked this conversation as resolved.
}
Comment thread
AndyButland marked this conversation as resolved.

Comment thread
AndyButland marked this conversation as resolved.
Outdated
#ensureHashPrefix(swatch: UmbSwatchDetails): UmbSwatchDetails {
Expand Down
Loading