question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:21 (20 by maintainers)

github_iconTop GitHub Comments

1reaction
crisbetocommented, Oct 1, 2021

This also feels a little weird to me since people would have to be familiar with the internals of the dispatcher in order to use the API. And as you mentioned, there’s the issue of double events. I’ll add this issue for discussion during our next team meeting to get some different perspectives on it.

1reaction
crisbetocommented, Sep 30, 2021

We generally try not to have drastically different behavior between tests and the real component. The _isTestEnvironment is used in two very specific cases that wouldn’t have an effect on the actual application.

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug(cdk/overlay): OverlayRef.outsidePointerEvents() should not emit ...
Steps to reproduce: Click open to open overlay; Mousedown inside the overlay, move mouse outside overlay and release click. Expected Behavior. OverlayRef.
Read more >
bug(cdk/overlay): Overlay out of viewport bounds · Issue #25059
It appears that when attempting to calculate whether or not the overlay will be within the view, the min-width and min-height will affect...
Read more >
Cannot Close Angular Material Cdkoverlay From BackdropClick
Everything with creating and launching the overlay works fine, it's just responding to the outside click. If I add hasBackdrop: true to ...
Read more >
Material CDK Overlay with RxJS - Medium
In my situation: user should be able quickly mouse over the opener element, the overlay should not be activated. only after the user...
Read more >
Using A "Drag Shield" To Block Mouse Events ... - Ben Nadel
Ben Nadel demonstrates how he uses a "drag shield" to act as an "event sink" during a drag-and-drop operation in his Angular 7.1.2 ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found