Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 19, 2025

  • Initial exploration and understanding of the DB Switch double event issue
  • Identify root cause in handleFrameworkEventAngular function
  • Implement initial fix for signal-based properties (checked and disabled)
  • Remove unrelated package.json and test artifacts from PR
  • Address architectural feedback about Angular ControlValueAccessor pattern
  • Remove writeValue call entirely for user-initiated events
  • Validate changes with build and tests
  • Final validation and testing

Problem Solved

The DB Switch component was triggering change events twice when using Angular signals. The root cause was in handleFrameworkEventAngular which incorrectly called both propagateChange and writeValue during user-initiated events.

Solution Evolution

Initial approach: Only skipped writeValue for signal-based properties (checked, disabled)

Final approach: Completely removed writeValue call for all user-initiated events, following proper Angular ControlValueAccessor pattern:

  • propagateChange: For view → model updates (user interactions) ✅
  • writeValue: Only for model → view updates (programmatic changes) ✅

This architectural fix resolves the double event issue for all affected components while maintaining proper Angular forms integration.

Impact

  • Components Fixed: db-switch, db-checkbox, db-tab-item, db-custom-select-list-item, db-input, db-textarea, db-select, db-radio, db-custom-select
  • Backward Compatibility: Full compatibility maintained for reactive forms, template-driven forms, and ngModel
  • Architecture: Now properly follows Angular ControlValueAccessor pattern

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

fixes #4599

@Copilot Copilot AI changed the title [WIP] DB Switch with signals as an controlled component triggers event two times Fix DB Switch double event firing with Angular signals Aug 19, 2025
@Copilot Copilot AI requested a review from mfranzke August 19, 2025 20:22
Copilot finished work on behalf of mfranzke August 19, 2025 20:22
@mfranzke
Copy link
Collaborator

@copilot I don't see a reason to modify package.json, package-lock.json or adding output/react/blob-report/report-d73910a.zip for this PR.

Copy link
Contributor Author

Copilot AI commented Aug 20, 2025

@copilot I don't see a reason to modify package.json, package-lock.json or adding output/react/blob-report/report-d73910a.zip for this PR.

You're absolutely right. I've removed the unrelated package.json, package-lock.json changes and the test artifact blob-report file from the PR. The PR now contains only the essential fix for the DB Switch double event firing issue in form-components.ts, plus a .gitignore update to prevent future test artifacts from being committed. Fixed in commit 439d623.

Copilot finished work on behalf of mfranzke August 20, 2025 06:44
@mfranzke mfranzke changed the title Fix DB Switch double event firing with Angular signals fix(DB Switch): double event firing with Angular signals Aug 20, 2025
Copy link

changeset-bot bot commented Sep 8, 2025

🦋 Changeset detected

Latest commit: b238811

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@db-ux/core-components Patch
@db-ux/ngx-core-components Patch
@db-ux/react-core-components Patch
@db-ux/v-core-components Patch
@db-ux/wc-core-components Patch
@db-ux/core-foundations Patch
@db-ux/core-stylelint Patch
@db-ux/core-migration Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@Copilot 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 a double event firing issue in the DB Switch component when using Angular signals. The root cause was improper implementation of the Angular ControlValueAccessor pattern in the handleFrameworkEventAngular function, which was calling both propagateChange and writeValue for user-initiated events.

Key changes:

  • Removed writeValue call from handleFrameworkEventAngular function to follow proper Angular ControlValueAccessor pattern
  • Added documentation explaining the distinction between propagateChange (view → model) and writeValue (model → view)
  • Added test showcase demonstrating the fix with Angular signals

Reviewed Changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 1 comment.

File Description
packages/components/src/utils/form-components.ts Core fix removing writeValue call and adding documentation for proper ControlValueAccessor pattern
showcases/angular-showcase/src/app/components/form/form.component.ts Test component setup with signal state and change handler
showcases/angular-showcase/src/app/components/form/form.component.html Test template demonstrating switch with Angular signals

@mfranzke mfranzke marked this pull request as draft September 22, 2025 06:49
auto-merge was automatically disabled September 22, 2025 06:49

Pull request was converted to draft

@michaelmkraus michaelmkraus marked this pull request as ready for review September 25, 2025 10:56
nmerget
nmerget previously approved these changes Sep 29, 2025
@nmerget nmerget enabled auto-merge (squash) September 29, 2025 12:07
@nmerget nmerget disabled auto-merge September 29, 2025 12:07
@nmerget nmerget self-requested a review September 29, 2025 12:15
@nmerget nmerget enabled auto-merge (squash) September 29, 2025 12:15
@github-actions github-actions bot added the 📕documentation Improvements or additions to documentation label Sep 29, 2025
@nmerget nmerget merged commit 4b87f4a into main Sep 29, 2025
54 checks passed
@nmerget nmerget deleted the copilot/fix-4599 branch September 29, 2025 13:30
@github-project-automation github-project-automation bot moved this from 👀 Actively In Review to ✅ Done in UX Engineering Team Backlog Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏘components 📕documentation Improvements or additions to documentation postReview 📺showcases Changes to 1-n showcases

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

DB Switch with signals as an controlled component triggers event two times

4 participants