@angular/cdk 12.2.7 → 12.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a11y/live-announcer/live-announcer.d.ts +1 -1
- package/bundles/cdk-a11y.umd.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.js +2 -1
- package/bundles/cdk-drag-drop.umd.js.map +1 -1
- package/bundles/cdk-overlay.umd.js +21 -2
- package/bundles/cdk-overlay.umd.js.map +1 -1
- package/bundles/cdk-platform.umd.js +12 -1
- package/bundles/cdk-platform.umd.js.map +1 -1
- package/bundles/cdk.umd.js +1 -1
- package/bundles/cdk.umd.js.map +1 -1
- package/esm2015/a11y/focus-monitor/focus-monitor.js +1 -1
- package/esm2015/a11y/live-announcer/live-announcer.js +1 -1
- package/esm2015/drag-drop/drag-ref.js +3 -2
- package/esm2015/overlay/dispatchers/overlay-outside-click-dispatcher.js +22 -3
- package/esm2015/overlay/overlay-ref.js +1 -1
- package/esm2015/platform/features/test-environment.js +13 -2
- package/esm2015/version.js +1 -1
- package/fesm2015/a11y.js.map +1 -1
- package/fesm2015/cdk.js +1 -1
- package/fesm2015/cdk.js.map +1 -1
- package/fesm2015/drag-drop.js +2 -1
- package/fesm2015/drag-drop.js.map +1 -1
- package/fesm2015/overlay.js +21 -2
- package/fesm2015/overlay.js.map +1 -1
- package/fesm2015/platform.js +12 -1
- package/fesm2015/platform.js.map +1 -1
- package/overlay/dispatchers/overlay-outside-click-dispatcher.d.ts +3 -0
- package/overlay/index.metadata.json +1 -1
- package/package.json +1 -1
- package/platform/index.metadata.json +1 -1
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-add/index.mjs +1 -1
|
@@ -941,9 +941,24 @@
|
|
|
941
941
|
var _this = _super.call(this, document) || this;
|
|
942
942
|
_this._platform = _platform;
|
|
943
943
|
_this._cursorStyleIsSet = false;
|
|
944
|
+
/** Store pointerdown event target to track origin of click. */
|
|
945
|
+
_this._pointerDownListener = function (event) {
|
|
946
|
+
_this._pointerDownEventTarget = i2._getEventTarget(event);
|
|
947
|
+
};
|
|
944
948
|
/** Click event listener that will be attached to the body propagate phase. */
|
|
945
949
|
_this._clickListener = function (event) {
|
|
946
950
|
var target = i2._getEventTarget(event);
|
|
951
|
+
// In case of a click event, we want to check the origin of the click
|
|
952
|
+
// (e.g. in case where a user starts a click inside the overlay and
|
|
953
|
+
// releases the click outside of it).
|
|
954
|
+
// This is done by using the event target of the preceding pointerdown event.
|
|
955
|
+
// Every click event caused by a pointer device has a preceding pointerdown
|
|
956
|
+
// event, unless the click was programmatically triggered (e.g. in a unit test).
|
|
957
|
+
var origin = event.type === 'click' && _this._pointerDownEventTarget
|
|
958
|
+
? _this._pointerDownEventTarget : target;
|
|
959
|
+
// Reset the stored pointerdown event target, to avoid having it interfere
|
|
960
|
+
// in subsequent events.
|
|
961
|
+
_this._pointerDownEventTarget = null;
|
|
947
962
|
// We copy the array because the original may be modified asynchronously if the
|
|
948
963
|
// outsidePointerEvents listener decides to detach overlays resulting in index errors inside
|
|
949
964
|
// the for loop.
|
|
@@ -958,8 +973,10 @@
|
|
|
958
973
|
continue;
|
|
959
974
|
}
|
|
960
975
|
// If it's a click inside the overlay, just break - we should do nothing
|
|
961
|
-
// If it's an outside click
|
|
962
|
-
|
|
976
|
+
// If it's an outside click (both origin and target of the click) dispatch the mouse event,
|
|
977
|
+
// and proceed with the next overlay
|
|
978
|
+
if (overlayRef.overlayElement.contains(target) ||
|
|
979
|
+
overlayRef.overlayElement.contains(origin)) {
|
|
963
980
|
break;
|
|
964
981
|
}
|
|
965
982
|
overlayRef._outsidePointerEvents.next(event);
|
|
@@ -978,6 +995,7 @@
|
|
|
978
995
|
// https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html
|
|
979
996
|
if (!this._isAttached) {
|
|
980
997
|
var body = this._document.body;
|
|
998
|
+
body.addEventListener('pointerdown', this._pointerDownListener, true);
|
|
981
999
|
body.addEventListener('click', this._clickListener, true);
|
|
982
1000
|
body.addEventListener('auxclick', this._clickListener, true);
|
|
983
1001
|
body.addEventListener('contextmenu', this._clickListener, true);
|
|
@@ -995,6 +1013,7 @@
|
|
|
995
1013
|
OverlayOutsideClickDispatcher.prototype.detach = function () {
|
|
996
1014
|
if (this._isAttached) {
|
|
997
1015
|
var body = this._document.body;
|
|
1016
|
+
body.removeEventListener('pointerdown', this._pointerDownListener, true);
|
|
998
1017
|
body.removeEventListener('click', this._clickListener, true);
|
|
999
1018
|
body.removeEventListener('auxclick', this._clickListener, true);
|
|
1000
1019
|
body.removeEventListener('contextmenu', this._clickListener, true);
|