Skip to content

feat(module:mention): support nzClear - #9377

Merged
Laffery merged 6 commits into
NG-ZORRO:masterfrom
Nicoss54:feature/mention-clear-support
Sep 6, 2025
Merged

Laffery merged 6 commits into
NG-ZORRO:masterfrom
Nicoss54:feature/mention-clear-support

Conversation

@Nicoss54

@Nicoss54 Nicoss54 commented Sep 2, 2025

Copy link
Copy Markdown
Collaborator

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?

Mention component now support nzClear icon

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@codecov

codecov Bot commented Sep 2, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.23%. Comparing base (d92568b) to head (62a1022).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
components/mention/mention.component.ts 90.90% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9377      +/-   ##
==========================================
- Coverage   92.27%   92.23%   -0.04%     
==========================================
  Files         560      560              
  Lines       19743    19759      +16     
  Branches     3029     3029              
==========================================
+ Hits        18217    18224       +7     
- Misses       1194     1203       +9     
  Partials      332      332              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread components/mention/mention.component.ts Outdated
Comment thread components/mention/mention.component.ts Outdated
Comment thread components/mention/mention-trigger.ts Outdated
Comment thread components/mention/mention-trigger.ts Outdated
@Nicoss54

Nicoss54 commented Sep 3, 2025

Copy link
Copy Markdown
Collaborator Author

@HyperLife1119 i have just updated the PR to avoid recreating the weel :) now it’s good :) thanks for your patience and review ! :)

@HyperLife1119

Copy link
Copy Markdown
Collaborator

Oh no, can you undo it? I don't recommend using nz-select-clear here because it's not abstract enough :(

@Nicoss54

Nicoss54 commented Sep 3, 2025

Copy link
Copy Markdown
Collaborator Author

Oh no, can you undo it? I don't recommend using nz-select-clear here because it's not abstract enough :(

Of course :)

@Nicoss54
Nicoss54 force-pushed the feature/mention-clear-support branch from 0036ce3 to 0a4cdab Compare September 3, 2025 06:54
@Nicoss54

Nicoss54 commented Sep 3, 2025

Copy link
Copy Markdown
Collaborator Author

Oh no, can you undo it? I don't recommend using nz-select-clear here because it's not abstract enough :(

Of course :)

@HyperLife1119 it’s revert :)

@HyperLife1119 HyperLife1119 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

Comment thread components/mention/demo/clear.ts
Comment thread components/mention/demo/clear.ts
Comment thread components/mention/mention.spec.ts
@Nicoss54

Nicoss54 commented Sep 6, 2025

Copy link
Copy Markdown
Collaborator Author

@HyperLife1119 could I merge it ?

Comment thread components/mention/mention-trigger.ts Outdated
} else {
this.elementRef.nativeElement.value = '';
}
this.value.set(value || '');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What if the user write a non-string value? There seems to be a different behavior with this PR

@Nicoss54 Nicoss54 Sep 6, 2025 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

But the type of value in the previous pr was a string. And it could be at the end only a string cause the directive is apply on an input or a text area so when we enter in the writeValue hook the value can only be a string or maybe I miss something in my reasoning ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The NzMentionTriggerDirective is deigned to used on an input or a textarea element, which value should be string you're right.

However, there is no type check with ngModel. for example:

@Component({
  imports: [FormsModule, NzMentionTriggerDirective],
  template: `
   <nz-mention [nzSuggestions]="suggestions" (nzOnSelect)="onSelect($event)">
      <textarea
        rows="1"
        placeholder="input here"
        nzMentionTrigger
        nz-input
        [(ngModel)]="value"
        (ngModelChange)="onChange($event)"
      ></textarea>
    </nz-mention>
  `
})
export class MentionTestComponent {
  value = model<object>({});
}

The result is

image

The previous result is

image

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ohhh I totally missed the use case of NgModel, that's true. I will revert this change and then I think we will be good

@Nicoss54

Nicoss54 commented Sep 6, 2025

Copy link
Copy Markdown
Collaborator Author

@Laffery change are done, I revert to the previous behavior

@Laffery Laffery left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Laffery
Laffery merged commit cbecebf into NG-ZORRO:master Sep 6, 2025
8 of 10 checks passed
@Nicoss54
Nicoss54 deleted the feature/mention-clear-support branch September 11, 2025 11:02
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.

3 participants