Skip to content

fix(angular): [v9] fix conditional flexRenderComponent rendering#6219

Open
riccardoperra wants to merge 3 commits intoalphafrom
fix/angular-component-conditional-rendering-v9
Open

fix(angular): [v9] fix conditional flexRenderComponent rendering#6219
riccardoperra wants to merge 3 commits intoalphafrom
fix/angular-component-conditional-rendering-v9

Conversation

@riccardoperra
Copy link
Copy Markdown
Collaborator

@riccardoperra riccardoperra commented Apr 2, 2026

#6218 for v9 branch

This resolve a rendering issue with flexRenderDirective that doesn't re-render component while using conditional flexRenderComponent return in the same cell column configuration (same cell reference in template, so it's a case where you are not updating table state but relies on external data outside of table scope)

cell: () => {
  if (condition) { 
    return flexRenderComponent(ComponentA)
  }
  return flexRenderComponent(ComponentB)
}

Example:

  • 1st call -> flexRenderComponent(ComponentA)
  • 2nd call -> flexRenderComponent(ComponentB)

Results

before: no-rerender since we were checking only A and B content type (which is always flexRenderComponent)

after: A will be destroyed and B will be created (since component type class is different)

Summary by CodeRabbit

  • Refactor

    • Enhanced component rendering system with improved type safety and more reliable change detection logic to ensure consistent component updates and reduce potential rendering issues.
  • Tests

    • Added comprehensive test coverage verifying that components correctly render and update dynamically when application state changes, including reactive component switching scenarios.
  • Chores

    • Updated dependency version specifications.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2026

📝 Walkthrough

Walkthrough

This PR refactors the Angular flex-render system to add stricter generic type constraints and an equality comparison mechanism for typed content. The change detection logic in the renderer is updated to compare content kinds and equality before updating. New tests verify dynamic component switching via reactive signals.

Changes

Cohort / File(s) Summary
Dependency Update
examples/react/row-selection/package.json
Updated @tanstack/react-devtools devDependency from exact version 0.10.1 to compatible range ^0.10.1.
Type System & Core Logic
packages/angular-table/src/flex-render/view.ts, packages/angular-table/src/flex-render/renderer.ts
Introduced FlexRenderViewAllowedType export and added second generic parameter TContent extends FlexRenderTypedContent to FlexRenderView. Implemented abstract eq() method for equality comparison in FlexRenderTemplateView and FlexRenderComponentView. Updated renderer change detection to compare content kinds and use equality checks before updates.
Flex-Render Tests
packages/angular-table/tests/flex-render/flex-render-table.test.ts, packages/angular-table/tests/flex-render/flex-render.unit.test.ts
Added comprehensive test cases verifying flexRenderComponent updates correctly when component class changes reactively via signals. Introduced test components TestABadgeComponent and TestBBadgeComponent with required inputs.
Import Reordering
packages/solid-table-devtools/src/production/plugin.tsx
Reordered import statements for TanStackDevtoolsPlugin type-only import.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Types flow tighter, like carrots in a row,
Components dance and switch when signals glow,
Equality checks keep renders true and keen,
The finest flex-render ever seen! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: resolving conditional flexRenderComponent rendering in Angular v9, which is the primary focus across the file changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/angular-component-conditional-rendering-v9

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@riccardoperra riccardoperra changed the title fix(angular): fix conditional flexRenderComponent rendering fix(angular): [v9] fix conditional flexRenderComponent rendering Apr 2, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 2, 2026

View your CI Pipeline Execution ↗ for commit df7d6bc

Command Status Duration Result
nx affected --targets=test:eslint,test:sherif,t... ✅ Succeeded 23s View ↗
nx run-many --targets=build -p @tanstack/table-... ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-03 09:07:57 UTC

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 2, 2026

More templates

@tanstack/angular-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/angular-table@6219

@tanstack/lit-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/lit-table@6219

@tanstack/match-sorter-utils

npm i https://pkg.pr.new/TanStack/table/@tanstack/match-sorter-utils@6219

@tanstack/preact-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/preact-table@6219

@tanstack/react-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/react-table@6219

@tanstack/react-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/react-table-devtools@6219

@tanstack/solid-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/solid-table@6219

@tanstack/solid-table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/solid-table-devtools@6219

@tanstack/svelte-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/svelte-table@6219

@tanstack/table-core

npm i https://pkg.pr.new/TanStack/table/@tanstack/table-core@6219

@tanstack/table-devtools

npm i https://pkg.pr.new/TanStack/table/@tanstack/table-devtools@6219

@tanstack/vue-table

npm i https://pkg.pr.new/TanStack/table/@tanstack/vue-table@6219

commit: df7d6bc

nx-cloud[bot]

This comment was marked as outdated.

This resolve a rendering issue with flexRenderDirective that doesn't re-render component while using conditional flexRenderComponent return in column configuration
@riccardoperra riccardoperra force-pushed the fix/angular-component-conditional-rendering-v9 branch from 010323e to 94aa6eb Compare April 2, 2026 20:20
nx-cloud[bot]

This comment was marked as outdated.

Copy link
Copy Markdown

@nx-cloud nx-cloud bot left a comment

Choose a reason for hiding this comment

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

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud is proposing a fix for your failed CI:

We reordered the imports in plugin.tsx to place the regular ./TableDevtools import before the import type declaration, resolving the import/order ESLint violation. This aligns with the workspace-wide convention (also enforced in the angular-table changes in this PR) that requires all value imports to precede type imports.

Tip

We verified this fix by re-running @tanstack/solid-table-devtools:test:eslint.

diff --git a/packages/solid-table-devtools/src/production/plugin.tsx b/packages/solid-table-devtools/src/production/plugin.tsx
index 39f442aa..94a8e230 100644
--- a/packages/solid-table-devtools/src/production/plugin.tsx
+++ b/packages/solid-table-devtools/src/production/plugin.tsx
@@ -1,6 +1,6 @@
 import { createSolidPlugin } from '@tanstack/devtools-utils/solid'
-import type { TanStackDevtoolsPlugin } from '@tanstack/devtools'
 import { TableDevtoolsPanel } from './TableDevtools'
+import type { TanStackDevtoolsPlugin } from '@tanstack/devtools'
 
 const [tableDevtoolsPluginFn] = createSolidPlugin({
   name: 'TanStack Table',

Apply fix via Nx Cloud  Reject fix via Nx Cloud


Or Apply changes locally with:

npx nx-cloud apply-locally TsDX-tI6j

Apply fix locally with your editor ↗   View interactive diff ↗



🎓 Learn more about Self-Healing CI on nx.dev

@riccardoperra riccardoperra marked this pull request as ready for review April 3, 2026 09:07
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/angular-table/tests/flex-render/flex-render.unit.test.ts (1)

1-17: Import ordering should be fixed per ESLint rules.

ESLint flags several import sorting issues:

  • ViewChild should come before signal alphabetically (line 5)
  • Type-only imports (TemplateRef, ComponentFixture) should use top-level type-only import syntax
  • FlexRenderDirective should come before flexRenderComponent alphabetically (line 14)
🔧 Proposed fix for import ordering
-import {
-  Component,
-  input,
-  signal,
-  ViewChild,
-  type TemplateRef,
-} from '@angular/core'
-import { TestBed, type ComponentFixture } from '@angular/core/testing'
+import {
+  Component,
+  input,
+  signal,
+  ViewChild,
+} from '@angular/core'
+import type { TemplateRef } from '@angular/core'
+import { TestBed } from '@angular/core/testing'
+import type { ComponentFixture } from '@angular/core/testing'
 import { createColumnHelper } from '@tanstack/table-core'
 import { describe, expect, test } from 'vitest'
 import {
   FlexRender,
+  FlexRenderDirective,
   flexRenderComponent,
-  FlexRenderDirective,
   injectFlexRenderContext,
 } from '../../src'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/angular-table/tests/flex-render/flex-render.unit.test.ts` around
lines 1 - 17, Reorder and adjust the imports to satisfy ESLint: place ViewChild
before signal in the Angular import list, move type-only imports (TemplateRef
and ComponentFixture) to top-level type-only import syntax (using `import type {
... } from '...'`), and alphabetize the named imports from '../../src' so
FlexRenderDirective comes before flexRenderComponent (ensure overall groups
remain logically ordered: Angular core, Angular testing, third-party, then
local). Ensure you update the import statements referencing TemplateRef and
ComponentFixture to use `import type` and reorganize the named imports to the
required alphabetical order.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/angular-table/tests/flex-render/flex-render.unit.test.ts`:
- Around line 1-17: Reorder and adjust the imports to satisfy ESLint: place
ViewChild before signal in the Angular import list, move type-only imports
(TemplateRef and ComponentFixture) to top-level type-only import syntax (using
`import type { ... } from '...'`), and alphabetize the named imports from
'../../src' so FlexRenderDirective comes before flexRenderComponent (ensure
overall groups remain logically ordered: Angular core, Angular testing,
third-party, then local). Ensure you update the import statements referencing
TemplateRef and ComponentFixture to use `import type` and reorganize the named
imports to the required alphabetical order.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5c787a37-e3a2-4ae2-a490-467599f6f0c3

📥 Commits

Reviewing files that changed from the base of the PR and between 357d582 and df7d6bc.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • examples/react/row-selection/package.json
  • packages/angular-table/src/flex-render/renderer.ts
  • packages/angular-table/src/flex-render/view.ts
  • packages/angular-table/tests/flex-render/flex-render-table.test.ts
  • packages/angular-table/tests/flex-render/flex-render.unit.test.ts
  • packages/solid-table-devtools/src/production/plugin.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant