The Popup provides events which facilitate common use cases such as closing the component after leaving the viewport and on document or Esc click.

After Leaving the Viewport

The anchorViewportLeave event is triggered when the anchor is scrolled outside the screen boundaries. When the anchor is not visible, use anchorViewportLeave to close the Popupotherwise, it will remain visible within the screen boundaries.

The control over the visibility of the Popup depends on you. As a result, when the container is scrolled, the Popup will not close automatically.

import { Component, ElementRef, Renderer2 } from '@angular/core';

  selector: 'my-app',
  template: `
    <div class="example">
        <div style="position: absolute">
            <h4>Parent with overflow:scroll</h4>
        <div class="parent-content" [scrollLeft]="250" [scrollTop]="250">
            <div class="content" [scrollLeft]="170" [scrollTop]="165">
              <button #anchor class="anchor k-button" (click)="onToggle()">Click me!</button>
              <kendo-popup class="popup" [anchor]="anchor" (anchorViewportLeave)="close()" *ngIf="show">
                <div class="popup-content">
                  Popup content.

              <span style="position: absolute; top: 400px; left: 400px">Bottom/Right</span>
            <span style="position: absolute; top: 600px; left: 600px">Bottom/Right</span>
  styles: [`
    .example {
        display: flex;
        position: relative;
        margin: auto 30px;
    .parent-content {
        position: relative;
        width: 300px;
        height: 300px;
        overflow: auto;
        margin: 100px auto;
        border: 2px solid #5ec232;
    .content {
        position: relative;
        width: 200px;
        height: 200px;
        overflow: auto;
        margin: 300px;
        border: 2px solid #3e80ed;
    .popup-content {
        padding: 30px 20px;
        color: #787878;
        background-color: #fcf7f8;
        border: 1px solid rgba(0,0,0,.05);

    .anchor {
        position: absolute;
        top: 200px;
        left: 200px;
class AppComponent {
    private show: boolean = false;

    public onToggle(): void { = !;

    public close(): void { = false;


On Document Click or Escape

To close the Popup when the user clicks outside its boundaries, wire the event and determine whether the Popup was clicked. If clicked, the Popup remains open.

The control over the visibility of the Popup depends on you. As a result, upon a document click or Esc press, the Popup will not close automatically.

In this article

Not finding the help you need?