From 4f0781c0a1590bee47c0b2d31972d25be7440a86 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Fri, 29 Sep 2023 10:42:09 +0200 Subject: [PATCH] Toggle color picker popover clicking preview button --- .../lib/uui-color-picker.element.ts | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/packages/uui-color-picker/lib/uui-color-picker.element.ts b/packages/uui-color-picker/lib/uui-color-picker.element.ts index 18e51e9c5..629b8157d 100644 --- a/packages/uui-color-picker/lib/uui-color-picker.element.ts +++ b/packages/uui-color-picker/lib/uui-color-picker.element.ts @@ -107,9 +107,6 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) { margin-left: 0.75rem; border-radius: 50%; } - color-picker__trigger { - cursor: pointer; - } .color-picker__preview::before, .color-picker__trigger::before { content: ''; @@ -488,7 +485,7 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) { event.stopImmediatePropagation(); const target = event.target as HTMLElement; - const popover = target.nextElementSibling as UUIPopoverElement; + const popover = target.parentElement as UUIPopoverElement; popover.open = !popover?.open; @@ -497,7 +494,7 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) { closeColorPicker(event: Event) { const target = event.target as UUIPopoverElement; - const trigger = target.previousElementSibling; + const trigger = target.querySelector("button[part=trigger]"); if (trigger) { trigger.setAttribute('aria-expanded', 'false'); @@ -653,27 +650,29 @@ export class UUIColorPickerElement extends LabelMixin('label', LitElement) { } private _renderPreviewButton() { - return html` + return html` +
${this._renderColorPicker()}
`; }