Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(module:cdkconnectedoverlay): supports disabling click on mask #8878

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

OriginRing
Copy link
Collaborator

@OriginRing OriginRing commented Nov 13, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Application (the showcase website) / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Copy link

zorro-bot bot commented Nov 13, 2024

This preview will be available after the AzureCI is passed.

Copy link

codecov bot commented Nov 13, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.84%. Comparing base (472bb34) to head (90214cb).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
components/tooltip/base.ts 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8878      +/-   ##
==========================================
- Coverage   91.88%   91.84%   -0.04%     
==========================================
  Files         537      537              
  Lines       18453    18473      +20     
  Branches     2814     2816       +2     
==========================================
+ Hits        16955    16966      +11     
- Misses       1196     1205       +9     
  Partials      302      302              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@Laffery Laffery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 comments, and please add unit tests

@@ -425,6 +432,10 @@ export abstract class NzTooltipBaseComponent implements OnDestroy, OnInit {
}

hide(): void {
if (!this.nzOverlayClickable) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two ways that invoke hide() method:

Take nz-popconfirm for an example,

  1. click outside overlay
  2. overlay detachments
<ng-template
      #overlay="cdkConnectedOverlay"
      cdkConnectedOverlay
      nzConnectedOverlay
      [cdkConnectedOverlayHasBackdrop]="nzBackdrop"
      [cdkConnectedOverlayOrigin]="origin"
      (overlayOutsideClick)="onClickOutside($event)"
      (detach)="hide()"
      (positionChange)="onPositionChange($event)"
      [cdkConnectedOverlayPositions]="_positions"
      [cdkConnectedOverlayOpen]="_visible"
      [cdkConnectedOverlayPush]="cdkConnectedOverlayPush"
      [nzArrowPointAtCenter]="nzArrowPointAtCenter"
    >
...
</ng-template>

If skip hiding the popconfirm here, the overlay detachments will not hide the popconfirm correctly.

So what about adding this condition at the onClickOutside method?

onClickOutside(event: MouseEvent): void {
+	if (!this.nzOverlayClickable) {
+		return;
+	}

  const target = _getEventTarget(event);
  if (!this.origin.nativeElement.contains(target) && this.nzTrigger !== null) {
    this.hide();
  }
}

@Laffery Laffery added PR: reviewed-changes-requested PR: need-test Test is necessary for code changes. and removed PR: unreviewed labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants