Ignore:
Timestamp:
11/25/21 22:08:24 (3 years ago)
Author:
Ema <ema_spirova@…>
Branches:
master
Children:
8d391a1
Parents:
59329aa
Message:

primeNG components

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trip-planner-front/node_modules/@angular/cdk/fesm2015/overlay.js

    r59329aa re29cc2e  
    597597        this._platform = _platform;
    598598        this._cursorStyleIsSet = false;
     599        /** Store pointerdown event target to track origin of click. */
     600        this._pointerDownListener = (event) => {
     601            this._pointerDownEventTarget = _getEventTarget(event);
     602        };
    599603        /** Click event listener that will be attached to the body propagate phase. */
    600604        this._clickListener = (event) => {
    601605            const target = _getEventTarget(event);
     606            // In case of a click event, we want to check the origin of the click
     607            // (e.g. in case where a user starts a click inside the overlay and
     608            // releases the click outside of it).
     609            // This is done by using the event target of the preceding pointerdown event.
     610            // Every click event caused by a pointer device has a preceding pointerdown
     611            // event, unless the click was programmatically triggered (e.g. in a unit test).
     612            const origin = event.type === 'click' && this._pointerDownEventTarget
     613                ? this._pointerDownEventTarget : target;
     614            // Reset the stored pointerdown event target, to avoid having it interfere
     615            // in subsequent events.
     616            this._pointerDownEventTarget = null;
    602617            // We copy the array because the original may be modified asynchronously if the
    603618            // outsidePointerEvents listener decides to detach overlays resulting in index errors inside
     
    614629                }
    615630                // If it's a click inside the overlay, just break - we should do nothing
    616                 // If it's an outside click dispatch the mouse event, and proceed with the next overlay
    617                 if (overlayRef.overlayElement.contains(target)) {
     631                // If it's an outside click (both origin and target of the click) dispatch the mouse event,
     632                // and proceed with the next overlay
     633                if (overlayRef.overlayElement.contains(target) ||
     634                    overlayRef.overlayElement.contains(origin)) {
    618635                    break;
    619636                }
     
    633650        if (!this._isAttached) {
    634651            const body = this._document.body;
     652            body.addEventListener('pointerdown', this._pointerDownListener, true);
    635653            body.addEventListener('click', this._clickListener, true);
    636654            body.addEventListener('auxclick', this._clickListener, true);
     
    650668        if (this._isAttached) {
    651669            const body = this._document.body;
     670            body.removeEventListener('pointerdown', this._pointerDownListener, true);
    652671            body.removeEventListener('click', this._clickListener, true);
    653672            body.removeEventListener('auxclick', this._clickListener, true);
Note: See TracChangeset for help on using the changeset viewer.