Summary
Hover/focus-triggered tooltips and popovers cannot be dismissed with the keyboard. Per WCAG 1.4.13 "Content on Hover or Focus", content shown on hover/focus must be dismissible without moving the pointer or focus — pressing Escape should hide it.
This is already shipped in the other editions; this issue tracks the Angular port for parity:
Scope
Both TooltipDirective and PopoverDirective (projects/coreui-angular/src/lib/{tooltip,popover}/*.directive.ts), free and pro.
Suggested approach
Both directives already drive visibility through the visible model signal. Mirror the pattern used in the other editions (React useEffect([_visible]), Vue watch(visible)): react to visible() and toggle a document-level keydown listener registered in the capture phase.
readonly #escapeEffect = effect((onCleanup) => {
if (!this.visible()) {
return;
}
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key !== 'Escape') {
return;
}
event.preventDefault();
event.stopPropagation();
this.visible.set(false);
};
this.#document.addEventListener('keydown', handleKeyDown, true);
onCleanup(() => this.#document.removeEventListener('keydown', handleKeyDown, true));
});
Notes:
- Capture phase (
true) is required — it lets a tooltip/popover shown inside a dialog dismiss before the dialog's own Escape handler (nested dismissal: first Escape closes the tooltip, the next closes the dialog).
#document is already injected (inject(DOCUMENT)); effect's onCleanup handles both visibility flips and teardown, so no separate ngOnDestroy wiring is needed. (An afterRenderEffect/plain listener via Renderer2.listen is an option too, but Renderer2.listen can't request the capture phase — use addEventListener directly.)
Tests
Add karma specs to both directives: (1) a shown tooltip/popover is hidden when Escape is dispatched on document; (2) a non-Escape key leaves it visible.
Docs
Add the same note the other editions use, under the tooltip/popover Usage section:
A shown tooltip can be dismissed by pressing the Escape key, helping satisfy the WCAG 1.4.13 "Content on Hover or Focus" success criterion.
Summary
Hover/focus-triggered tooltips and popovers cannot be dismissed with the keyboard. Per WCAG 1.4.13 "Content on Hover or Focus", content shown on hover/focus must be dismissible without moving the pointer or focus — pressing Escape should hide it.
This is already shipped in the other editions; this issue tracks the Angular port for parity:
_setEscapeListener())Scope
Both
TooltipDirectiveandPopoverDirective(projects/coreui-angular/src/lib/{tooltip,popover}/*.directive.ts), free and pro.Suggested approach
Both directives already drive visibility through the
visiblemodel signal. Mirror the pattern used in the other editions (ReactuseEffect([_visible]), Vuewatch(visible)): react tovisible()and toggle a document-levelkeydownlistener registered in the capture phase.Notes:
true) is required — it lets a tooltip/popover shown inside a dialog dismiss before the dialog's own Escape handler (nested dismissal: first Escape closes the tooltip, the next closes the dialog).#documentis already injected (inject(DOCUMENT));effect'sonCleanuphandles both visibility flips and teardown, so no separatengOnDestroywiring is needed. (AnafterRenderEffect/plain listener viaRenderer2.listenis an option too, butRenderer2.listencan't request the capture phase — useaddEventListenerdirectly.)Tests
Add karma specs to both directives: (1) a shown tooltip/popover is hidden when Escape is dispatched on
document; (2) a non-Escape key leaves it visible.Docs
Add the same note the other editions use, under the tooltip/popover Usage section: