-
Notifications
You must be signed in to change notification settings - Fork 133
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(core): address Avatar Group issues #12530
base: main
Are you sure you want to change the base?
Changes from 23 commits
22be6e6
4a87b4d
b39b871
aedf05e
b32ae7e
fe4920e
0ead287
1f11a17
da922ad
f587f50
4373cde
b6af950
3768cb9
f79c75e
3405d09
3a61be4
8b1e6de
8251f84
d20946e
cb1c93d
d353a20
18fc966
827ef21
d4bd252
bc16f40
728a86b
87c2469
fada1bc
3420564
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add or update relevant unit tests for maxVisibleItems There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is not e2e test for avatar group host |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,8 @@ import { | |
Renderer2, | ||
TemplateRef, | ||
ViewContainerRef, | ||
inject | ||
inject, | ||
signal | ||
} from '@angular/core'; | ||
import { Observable, Subject, merge } from 'rxjs'; | ||
import { distinctUntilChanged, filter, startWith, takeUntil } from 'rxjs/operators'; | ||
|
@@ -46,6 +47,9 @@ export class PopoverService extends BasePopoverClass { | |
/** Template content displayed inside popover body */ | ||
templateContent: Nullable<TemplateRef<any>>; | ||
|
||
/** Whether to focus the first item on space key press */ | ||
_forceFocus = signal(false); | ||
|
||
/** @hidden */ | ||
_onLoad = new Subject<ElementRef>(); | ||
|
||
|
@@ -127,6 +131,13 @@ export class PopoverService extends BasePopoverClass { | |
this._removeOverlay(this._modalBodyClass, this._modalTriggerClass); | ||
} | ||
}); | ||
|
||
// Add keydown listener for space key | ||
this._renderer.listen('document', 'keydown', (event: KeyboardEvent) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Listening for keydown events globally on the document level can lead some performance issues, if it is possible scope the event listener to the popover element directly. this._renderer.listen(popoverElement, 'keydown', (event: KeyboardEvent) => { |
||
if (event.code === 'Space' && this.isOpen) { | ||
this._storeAndFocusFirstTabbable(); | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
|
@@ -588,11 +599,16 @@ export class PopoverService extends BasePopoverClass { | |
/** @hidden */ | ||
private _focusFirstTabbableElement(focusLastElement = true): void { | ||
if (focusLastElement && this.focusAutoCapture) { | ||
this._lastActiveElement = <HTMLElement>document.activeElement; | ||
this._getPopoverBody()?._focusFirstTabbableElement(); | ||
this._storeAndFocusFirstTabbable(); | ||
} | ||
} | ||
|
||
/** @hidden */ | ||
private _storeAndFocusFirstTabbable(): void { | ||
this._lastActiveElement = <HTMLElement>document.activeElement; | ||
this._getPopoverBody()?._focusFirstTabbableElement(true); | ||
} | ||
|
||
/** @hidden */ | ||
private _focusLastActiveElementBeforeOpen(focusLastElement = true): void { | ||
if (focusLastElement && this.restoreFocusOnClose && this.focusAutoCapture && this._lastActiveElement) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use Nullable type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PopoverPlacement type is Placement | null. It's not Nullable. If I change it I'm afraid it will broke already existing functionality