Skip to content

docs-bug(cdk-overlay): Add missing detach handler in overlay example #30185

@aghwotu

Description

@aghwotu

Documentation Feedback

The CDK Overlay example is missing a crucial event handler. Specifically, when using the ESC key to close the overlay, the parent component's state isn't properly updated, leading to inconsistent behavior:

  1. Current behavior (demonstrated in the StackBlitz):

    • Closing with ESC requires two clicks to reopen
  2. The solution is to add the detach handler (demonstrated in the StackBlitz):

<ng-template
  cdkConnectedOverlay
  [cdkConnectedOverlayOrigin]="trigger"
  [cdkConnectedOverlayOpen]="isOpen"
  (detach)="isOpen = false"  <!-- Add this line -->
>
  <!-- content -->
</ng-template>

Here is a StackBlitz link that demonstrates both the issue and the working solution with the detach handler. I'm ready to submit a PR implementing these changes once this approach is confirmed.

Affected documentation page

https://material.angular.io/cdk/overlay/overview

Metadata

Metadata

Assignees

Labels

P4A relatively minor issue that is not relevant to core functionsarea: cdk/overlaydocsThis issue is related to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions