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 item-selection on dropdown with popover in safari #2356

Merged
merged 4 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -173,5 +173,22 @@ describe('DropdownComponent + PopoverComponent', () => {
it('should have options be visible', () => {
expect(cardElement).toBeVisible();
});

it('should select the selected item', () => {
const expectedItem = items[0];

spectator.click('kirby-item');

expect(spectator.component.value).toEqual(expectedItem);
});

it('should emit change event with the selected item', () => {
const expectedItem = items[0];
const onChangeSpy = spyOn(spectator.component.change, 'emit');

spectator.click('kirby-item');

expect(onChangeSpy).toHaveBeenCalledWith(expectedItem);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
<ng-container *ngTemplateOutlet="usePopover ? popoverTemplate : itemWrapperTemplate"></ng-container>

<ng-template #popoverTemplate>
<kirby-popover [target]="buttonElement" [popout]="popout" (willHide)="_onPopoverWillHide()">
<kirby-popover
[target]="buttonElement"
[popout]="popout"
(click)="_onPopoverClick($event)"
(willHide)="_onPopoverWillHide()"
>
<ng-container *ngTemplateOutlet="itemWrapperTemplate"></ng-container>
</kirby-popover>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,14 +471,19 @@ export class DropdownComponent

@HostListener('keydown.enter')
@HostListener('keydown.escape')
_onEnterOrEsscape(event?: FocusEvent) {
mictro marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting the following linting error on this line:
[tsserver 6133] [I] 'event' is declared but its value is never read.

this.close();
this._onTouched();
}

_onPopoverClick(event: PointerEvent) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting the following linting error on this line:
[tsserver 6133] [I] 'event' is declared but its value is never read.

this.close();
}

@HostListener('blur', ['$event'])
_onBlur(event?: FocusEvent) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting the following linting error on this line:
[tsserver 6133] [I] 'event' is declared but its value is never read.

if (this.disabled) return;
if (this.isOpen) {
if (!this.cardElement.nativeElement.contains(event?.relatedTarget as HTMLElement)) {
this.close();
}
}
if (this.usePopover) return;
this.close();
this._onTouched();
}

Expand Down