Skip to content

bug(cdk/overlay): OverlayRef.outsidePointerEvents() should not emit with mousedown inside overlay and mouseup outside it #23643

Closed
@kyubisation

Description

@kyubisation

Reproduction

Use StackBlitz to reproduce your issue:
https://stackblitz.com/edit/components-issue-iikzo4?file=src%2Fmain.ts

Steps to reproduce:

  1. Click open to open overlay
  2. Mousedown inside the overlay, move mouse outside overlay and release click

Expected Behavior

OverlayRef.outsidePointerEvents() does not emit, since the mouse down did originate inside the overlay.
This is useful in scenarios where users want to mark text inside and overlay and copy it, but might move the cursor outside the overlay.

Actual Behavior

OverlayRef.outsidePointerEvents() emits (see console)

Additional notes

I implemented a workaround by replacing the 'click' event with the 'mousedown'; See overlay-outside-click-dispatcher.service.ts and main.ts:37-42
It is also certainly possible to implement a workaround that does not rely on outsidePointerEvents(), but it would be far easier to use it.

Unfortunately I don't know whether the current behavior is intentional by the components team or merely an oversight.

Environment

  • Angular: 12.2.5
  • CDK/Material: 12.2.5
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: cdk/overlayneeds: discussionFurther discussion with the team is needed before proceeding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions