Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/violet-ends-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sl-design-system/time-field': patch
---

Fixes toggling time picker when clicking on the clock button.
13 changes: 13 additions & 0 deletions packages/components/time-field/src/time-field.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,19 @@ describe('sl-time-field', () => {
expect(dialog).to.exist;
expect(dialog).to.match(':popover-open');
});

it('should toggle the popover when clicking the clock button', () => {
const dialog = el.renderRoot.querySelector<HTMLElement>('dialog')!;

expect(dialog).to.exist;
expect(dialog?.matches(':popover-open')).to.be.false;

button?.click();
expect(dialog?.matches(':popover-open')).to.be.true;

button?.click();
expect(dialog?.matches(':popover-open')).to.be.false;
});
});

describe('text field', () => {
Expand Down
8 changes: 7 additions & 1 deletion packages/components/time-field/src/time-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,13 @@ export class TimeField extends LocaleMixin(FormControlMixin(ScopedElementsMixin(
}
}

#onButtonClick(): void {
#onButtonClick(event: MouseEvent): void {
event.stopPropagation();

if (this.disabled || this.readonly) {
return;
}

// Prevents the popover from reopening immediately after it was just closed
if (!this.#popoverJustClosed) {
this.dialog?.togglePopover();
Expand Down