Skip to content

fix(module:input): update disable logic to support Angular Signal Forms#9701

Open
Nicoss54 wants to merge 1 commit intoNG-ZORRO:masterfrom
Nicoss54:fix/disable-signal-forms
Open

fix(module:input): update disable logic to support Angular Signal Forms#9701
Nicoss54 wants to merge 1 commit intoNG-ZORRO:masterfrom
Nicoss54:fix/disable-signal-forms

Conversation

@Nicoss54
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?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@Nicoss54 Nicoss54 requested a review from vthinkxie as a code owner February 20, 2026 08:41
Copilot AI review requested due to automatic review settings February 20, 2026 08:41
@Nicoss54 Nicoss54 self-assigned this Feb 20, 2026
@Nicoss54 Nicoss54 requested a review from Laffery February 20, 2026 08:41
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Nicoss54, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a compatibility issue within the nz-input directive, specifically related to how it handles disabled states when integrated with Angular Signal Forms. The changes ensure that the input directive accurately reflects the disabled status of form controls managed by the new signal-based forms API, providing a robust solution for this interaction.

Highlights

  • Angular Signal Forms Compatibility: Updated the controlDisabled signal in NzInputDirective to correctly react to disabled states from InteropNgControl used by Angular Signal Forms, ensuring proper disable logic.
Changelog
  • components/input/input.directive.ts
    • Updated the controlDisabled signal to use linkedSignal for better compatibility with Angular Signal Forms' InteropNgControl.
Activity
  • No specific review comments or activity have been recorded yet for this pull request.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request addresses a bug related to the disabled logic in NzInputDirective to support Angular Signal Forms. The change introduces linkedSignal to reactively update the controlDisabled state, which is a good step towards better integration with Angular's signal-based reactivity. The comments in the code explain the rationale behind this change, acknowledging it as a temporary workaround until Signal Forms API stabilizes. The changes are focused and directly address the described bug.

Comment on lines +90 to +96
// Angular Signal Forms uses `InteropNgControl` which does not emit `statusChanges`.
// However, `InteropNgControl.disabled` is signal-reactive (it reads from the field's
// computed disabled signal), so an `effect()` here picks up changes for Signal Forms
// while remaining a one-shot read for traditional reactive forms (whose updates
// continue to come from the `statusChanges` subscription in `ngOnInit`).
// I think this is "nice" workaround for now, but we should find a better solution in the future when signal form API will be stable.
readonly controlDisabled = linkedSignal(() => !!this.ngControl?.disabled || false);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The extensive comment block here is helpful for understanding the immediate problem and the chosen workaround. However, it's quite verbose for an inline code comment. Consider shortening it or moving some of the detailed explanation to a separate documentation file or a more high-level comment if this is a known temporary solution. While the explanation is good, the code should ideally be self-documenting or have concise comments.

// while remaining a one-shot read for traditional reactive forms (whose updates
// continue to come from the `statusChanges` subscription in `ngOnInit`).
// I think this is "nice" workaround for now, but we should find a better solution in the future when signal form API will be stable.
readonly controlDisabled = linkedSignal(() => !!this.ngControl?.disabled || false);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The use of linkedSignal is appropriate here for creating a signal that derives its value from another signal (this.ngControl?.disabled). This aligns with the Angular best practices for state management using signals, as outlined in the repository's style guide (lines 32-33). The !! operator ensures a boolean value, which is good for consistency.

References
  1. Use signals for state management and computed() for derived state. (link)

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.

yeah it seems there is a miss in Angula documentation but in the case of signal form this.ngControl?.disabled is a signal

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the disabled state handling in the input directive to support Angular Signal Forms. The change updates controlDisabled from a simple signal to a linkedSignal that reactively tracks ngControl?.disabled, which works with both traditional reactive forms (via the existing statusChanges subscription) and newer Signal Forms (via reactive signal tracking).

Changes:

  • Modified controlDisabled to use linkedSignal() with a computation function that reads ngControl?.disabled
  • Added detailed comment explaining the workaround for Signal Forms compatibility

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.10%. Comparing base (d99675f) to head (4a9a0aa).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9701   +/-   ##
=======================================
  Coverage   90.10%   90.10%           
=======================================
  Files         574      574           
  Lines       23671    23671           
  Branches     4814     4814           
=======================================
+ Hits        21328    21329    +1     
  Misses       1520     1520           
+ Partials      823      822    -1     

☔ 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.

@Nicoss54 Nicoss54 force-pushed the fix/disable-signal-forms branch from 33717eb to 4a9a0aa Compare February 20, 2026 08:52
@Nicoss54
Copy link
Copy Markdown
Collaborator Author

Nicoss54 commented Mar 3, 2026

@HyperLife1119 @Laffery when you have time could you also take a look ? :)

@HyperLife1119
Copy link
Copy Markdown
Collaborator

I'm not sure if it's a good idea to be compatible with signal form before it's stable (at least in developer preview), but I've seen a PR that will implement statusChanges for InteropNgControl.

@Laffery
Copy link
Copy Markdown
Collaborator

Laffery commented Mar 3, 2026

I'm not sure if it's a good idea to be compatible with signal form before it's stable (at least in developer preview)

+1

@Laffery
Copy link
Copy Markdown
Collaborator

Laffery commented Mar 3, 2026

BTW, is this PR related to #9642? @Nicoss54

@Nicoss54
Copy link
Copy Markdown
Collaborator Author

Nicoss54 commented Mar 3, 2026

@HyperLife1119 @Laffery I also agree with both of you ! This was just a quick win to unblock the issue @Laffery mentionned. But agree to close it

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.

[nz-input] Input is not disabled on initial render when using signal form

4 participants