Unplanned
Last Updated: 30 Jan 2025 08:11 by ADMIN
Herman
Created on: 23 Jan 2025 11:00
Category: Popup
Type: Feature Request
3
Simplify Popup Implementation with Default Close on Outside Click
I would like to suggest simplifying the popup implementation by including a default mechanism to close the popup when the user clicks outside its boundaries.

Currently, this functionality requires additional code, such as the example below:

Documentation reference:
https://www.telerik.com/kendo-angular-ui/components/popup/closing#on-document-click-or-escape
@ViewChild("anchor", { read: ElementRef }) public anchor: ElementRef;
@ViewChild("popup", { read: ElementRef }) public popup: ElementRef;

@HostListener("document:keydown", ["$event"])
public keydown(event: KeyboardEvent): void {
  if (event.code === "Escape") {
    this.closePopup();
  }
}

@HostListener("document:click", ["$event"])
public documentClick(event: KeyboardEvent): void {
  if (!this.contains(event.target)) {
    this. closePopup();
  }
}

private contains(target: EventTarget): boolean {
  return (
    this.anchor.nativeElement.contains(target) ||
    (this.popup ? this.popup.nativeElement.contains(target) : false)
  );
}
Including this functionality as a default in the popup component would eliminate the need to write repetitive code for every use of the popup component.

Thank you for considering this enhancement.

Kind regards,
Herman Fransen
1 comment
ADMIN
Martin Bechev
Posted on: 30 Jan 2025 08:11

Hi Herman,

Thank you for the provided feedback and suggestions.

We will monitor the customer demand for this item and consider adding it to our Roadmap based on the interest.

I also added your vote to the item.

Regards,
Martin Bechev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.