Skip to content

UI: Angular 21 (from 18.2), with PrimeNG 21 and Nx 22 - #44

Open
belkassaby wants to merge 9 commits into
mainfrom
chore/angular-21
Open

belkassaby wants to merge 9 commits into
mainfrom
chore/angular-21

Conversation

@belkassaby

@belkassaby belkassaby commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Updates the v3 UI (ui/) from Angular 18.2 to Angular 21.2, and moves it onto Angular 21's idiomatic features: signal inputs, outputs and queries, and zoneless change detection (zone.js removed). One Angular major per commit, each with its own migrations and a full check. PrimeNG has to follow: PrimeNG 17 supports Angular 17–18 only, and from 18 its major tracks Angular's.

Commits

Commit Change
16b87ff4 Angular 19.2. Nx 20.8 already supported Angular 19 but the update had been skipped, so it's replayed with nx migrate --from=@nx/angular@20.1.0 --exclude-applied-migrations. Standalone is now the default, so 30 standalone: true lines go.
5c6c433d Angular 20.3, Nx 21.6, TypeScript 5.9, angular-eslint 20. Its new prefer-inject rule is met with Angular's own inject() migration (16 files).
11d05202 Built-in control flow (@if, @for, @switch) via Angular's migration. *ngIf and the others are deprecated from 20. One block had to be restructured first: the analyze page's options ngSwitch held comments and help text beside its cases. A separate commit, so it's easy to review or revert.
cbf70823 Angular 21.2, Nx 22.7, Jest 30, jest-preset-angular 16, zone.js 0.16, ng-mocks 14.18 (the first release that takes Angular 21).
711b0c35 PrimeNG 21.1: the theme as a preset, replacements for removed components, and fixes for what changed (details below). Also @types/node 22, and lazy loading for the gene set page.
578b2943 Docs; the old Bitbucket pipeline's Node image raised to Angular 21's minimum (22.12).
d348d62c Signals, using Angular's own migrations: 51 @Input become input(), 14 @Output become output(), 19 @ViewChild become viewChild(). Inputs the component also writes, paired with an xChange output, become model(): the search filters, the view switch, the search bar's text and the gene list's genes. Tests set inputs with setInput.
d2e81a11 Zoneless: provideZonelessChangeDetection(), with zone.js removed (details below).
4e58bcb9 Fix: search result rows expand again (found on dev). PrimeNG 21 no longer reads the table's rowexpansion template, so the chevron did nothing.

PrimeNG 17 → 21, kept looking the same

PrimeNG 18+ ships no theme CSS. The aura-light-green theme file becomes providePrimeNG with Aura and a green primary (src/app/theme.ts), light only. The old file did more than color components, so this restores the rest in styles.scss:

  • Inter, which the theme file shipped and set on :root. It now comes from @fontsource-variable/inter, the same OFL-licensed font.
  • .p-component { font-weight: normal }, so components inside the search page's font-bold block stay regular. PrimeNG's own component weights still win, because its styles are injected after this sheet.
  • PrimeNG 17's CSS variables, which PrimeFlex's utility classes (text-color-secondary, surface-border, bg-green-100...) and the species tags read. The theme tokens point at PrimeNG's new --p-* tokens. The named color scales keep 17's exact values, because only the app and PrimeFlex use them.

Removed or changed in PrimeNG, handled so nothing looks different:

  • Dropdown → Select. Messages → Message for the top banner, with its content kept in one row as before.
  • Tag severity warning is now warn (Tier III).
  • p-message has no default icon any more, so the analyze page's messages set theirs.
  • p-divider now centers its label by default; the gene set page's dividers are set to left, as they rendered before.
  • Styles are injected only for components actually in use. So the buttons, inputs and selects that relied on p-button / p-inputtext classes alone now get the pButton / pInputText directives (about 40 elements). Otherwise they'd only look right on pages that happened to render a real PrimeNG button.
  • AutoComplete's internal class names changed, so the gene set suggestion list's style overrides follow.
  • responsiveLayout="stack" is no longer implemented, so nothing hid the gene set list's per-cell titles any more; the list hides them itself. It never actually stacked: PrimeNG 17 scrolls a scrollable table instead.
  • The table's rowexpansion template is now expandedrow. Under the old name PrimeNG ignores it, so the search results' expand chevron did nothing. Renamed, with a test that expands and collapses a row. The app's other template names are all still read.
  • p-button-secondary now colors a menubar item, so the gene set page's "Legacy Page" item drops it.

Zoneless

Without zone.js, Angular re-renders only when a template event, a signal, the async pipe or markForCheck says the view changed, not after every timer, promise or HTTP response. So every change made outside a template event now notifies Angular:

  • Page components that set plain fields in subscriptions (analyze, gene set, similar gene sets, gene set search, gene set picker, search bar) put renderAfter(changes) before .subscribe(...). It's a small operator that marks the component for checking after each emission (utils/render-after.ts), and covers 16 subscriptions.
  • The shared search source calls back its owner when results arrive. The home spinner is a signal.
  • Already notifying: the charts call markForCheck in their D3 and Cytoscape handlers, the gene list's genes are a model signal, and outputs and the async pipe notify by themselves.
  • Tests run in jest-preset-angular's zoneless environment. The two polling tests use Jest's fake timers instead of fakeAsync, which needs zone.js. The analyze tests mark the component before re-rendering after changing its state directly, as the app does.

The large pages keep their state as plain fields with explicit markForCheck. That's Angular's documented zoneless pattern for existing code. Rewriting their state as signals touches every binding in templates of up to 800 lines, so it's left for later, page by page.

Bundle size

With Angular 21 and PrimeNG 21, the initial bundle reached 2.03 MB. That's past the 2 MB error budget of the stage and prod build configurations, so the release build would fail. The gene set page is now lazy-loaded, as the analyze page already was. The initial bundle is 1.90 MB, and the page loads as its own 132 kB chunk. Without zone.js it's 1.86 MB.

Testing

  • Clean npm ci, strict peer dependencies (no --legacy-peer-deps), Node 22:
    • Jest: 429 / 429 tests pass, in 32 suites: main's 428, plus the row expansion test. That's after the signal changes too, in the zoneless test environment.
    • nx lint: clean.
    • npm run build:jax-cluster-dev-10 and build:jax-cluster-prod-10: all four environments build. Stage and prod give only the size warnings main already had.
  • Visual check in headless Chrome, against main's build, with dev's API port-forwarded (read-only, signed out):
    • pages: home, search results (1400 px and 800 px), a gene set (GS880), and the analyze page;
    • they match, apart from gene set names in the results being slightly heavier, since PrimeNG 21's button labels default to weight 500.
    • Not covered: anything behind sign-in, and tool result charts. Worth a look on dev.
  • Zoneless behaviour, driven in Chrome with puppeteer against dev's API (read-only, signed out). Each update renders, with no console errors:
    • a search from the URL;
    • a typed search;
    • the next page;
    • a gene set's details and genes;
    • refetching the genes by another identifier type;
    • the analyze tool list;
    • the gene set picker's suggestions, with the AutoComplete dropdown open.
  • npm audit: 122 → 89 findings in total (critical 7 → 3, high 65 → 30). Production dependencies only: 10 → 8.

For reviewers

  • The intermediate commits install with --legacy-peer-deps, because PrimeNG 17's peer range blocks Angular 19+ until the PrimeNG commit. The final lockfile resolves strictly; CI's npm ci is the check.
  • ngx-csv is still CommonJS (a warning on the gene set page, as on main).

Nx 20.8 already supports Angular 19, but the Angular update had been skipped; it is
replayed with nx migrate --from=@nx/angular@20.1.0 --exclude-applied-migrations.

- @angular/* 19.2.9, zone.js 0.15, angular-eslint 19.8, jest-preset-angular 14.4.
- Components are standalone by default in 19, so the explicit standalone: true is
  dropped (Angular's explicit-standalone-flag migration, reduced to that one line).
- angular-eslint's prefer-standalone rule is off, as Nx's migration sets it.

PrimeNG stays on 17 until its own step; its peer range (Angular <= 18) is why this
step installs with --legacy-peer-deps.
…heir migrations

- @angular/* 20.3.9, @angular/cli 20.3, Nx 21.6.11, angular-eslint 20.7,
  jest-preset-angular 14.6, TypeScript ~5.9.3 (Angular 20 needs 5.8+, 21 needs 5.9).
- Nx's migrations: moduleResolution bundler, the serve target continuous, generator
  defaults that keep the pre-v20 file naming, ignore entries for Nx's AI rule files.
- angular-eslint 20 recommends prefer-inject, so constructor injection moves to
  inject() with Angular's own inject migration (16 files), imports kept multi-line.
- VennComponent imported NgFor without using it (Angular 20's NG8113 warning).

The template control-flow migration is the next commit, on its own.
*ngIf, *ngFor and *ngSwitch are deprecated from Angular 20. Converted with Angular's
control-flow migration (33 files). It could not take the analyze page's options block:
its [ngSwitch] element also held two comments and the help text, which @switch does not
allow beside its cases, so the switch moved to an inner ng-container holding only the
cases and the analyze templates were migrated after. Inside @if (session.current && ...)
the session is narrowed, so its ?. became . (NG8107).
…grations

- @angular/* 21.2.9, @angular/cli 21.2, zone.js 0.16, Nx 22.7.12, angular-eslint 21.4.
- Jest 30 with jest-preset-angular 16: the setup file uses setupZoneTestEnv, and the
  Jest config is CommonJS (Nx's migrations).
- TypeScript configs: moduleResolution bundler, module preserve, lib es2022,
  isolatedModules for specs (Nx's migrations).
- ng-mocks 14.18.6, the first release whose peer range takes Angular 21.
- Nx adds ignore entries for its own generated folders.

Angular's own 21 migrations found nothing to change.
…t it removed

PrimeNG 17 supports Angular 17-18 only; from 18 its major follows Angular's.

- primeng ^21.1.10, @angular/cdk 21.2.9 (now a peer), @primeuix/themes ^2.0.3.
- Theme: PrimeNG 18+ ships no theme CSS; the aura-light-green file becomes
  providePrimeNG with Aura and a green primary (src/app/theme.ts), light only.
- What the theme file used to provide, restored in styles.scss:
  - Inter, which it shipped and set on :root (@fontsource-variable/inter);
  - .p-component's normal weight, so components inside bold text stay regular;
  - PrimeNG 17's CSS variables, which PrimeFlex's utilities and the species tags read:
    theme tokens point at PrimeNG's --p-* ones, named colour scales keep 17's values.
- Removed components: Dropdown -> Select, Messages -> Message (the top banner, its
  content kept in one row, as p-messages laid it out).
- Changed behaviour, kept as it looked:
  - Tag severity "warning" is "warn";
  - p-message has no default icon, so the analyze page's messages name theirs;
  - Divider centres its label by default, so the gene set page's are left-aligned;
  - styles are injected only for components in use, so buttons and inputs styled
    with p-button / p-inputtext get pButton / pInputText;
  - AutoComplete's internal class names, which the suggestion list styles, renamed;
  - responsiveLayout="stack" is no longer implemented, so the gene set list hides its
    per-cell titles itself (it never stacked: PrimeNG 17 scrolls a scrollable table);
  - p-button-secondary now colours a menubar item, so the Legacy Page item drops it.
- @types/node 22, as CI runs Node 22 (Vite's peer range wants 20.19+).
- The gene set page is lazy-loaded, as the analyze page already was: with Angular 21
  and PrimeNG 21 the initial bundle reached 2.03 MB, past stage/prod's 2 MB error
  budget; it is 1.90 MB.

Checked against main's build in headless Chrome with dev's data: home, search results
(wide and narrow), a gene set, and the analyze page match apart from button labels at
weight 500.
… pipeline's Node meets Angular 21's minimum

Angular 21 needs Node 22.12 or later. GitHub Actions already sets up Node 22 (latest 22.x);
ui/bitbucket-pipelines.yml, from the standalone repo, pinned node:22.6. The UI uses
PrimeFlex, not Tailwind.
…or two-way state

Angular's own migrations (signal-input, output, signal-queries), across the UI:
51 @input become input() / input.required(), 14 @output become output(), 19
@ViewChild become viewChild(). Safe mode skipped 17 inputs; best-effort mode took
them, and what it needed by hand:

- Inputs the component also writes become model(): the search filters' `filters`,
  the view switch's `value`, the search bar's `searchValue` (bound with
  [(ngModel)]), and the gene list's `genes` (given by the parent, or fetched for a
  gene set id). Their `(xChange)` bindings are unchanged.
- output() refuses undefined where EventEmitter took it: `searchPaging` emits a
  response's paging, absent on some responses, so its type says Paging | undefined.
- The Venn species table narrows its signal with @if (species(); as rows).
- Tests set inputs as a parent template does, with fixture.componentRef.setInput,
  not by assignment (which would replace the signal). setInput is a real input
  change, so the gene network test lets Angular run ngOnChanges once and waits for
  Cytoscape to load, instead of also calling it by hand.
provideZonelessChangeDetection replaces zone.js. Angular now re-renders when a template
event, a signal, the async pipe or markForCheck says the view changed -- not after every
timer, promise or HTTP response. Every change made outside a template event now says so:

- Page components whose state is plain fields set in subscriptions (analyze, gene set,
  similar gene sets, gene set search, gene set picker, search bar) mark themselves for
  checking after each emission with renderAfter(changes), a small operator put before
  .subscribe(...) (utils/render-after.ts): 16 subscriptions.
- GenesetSearchSource, shared by the search and the picker, calls back its owner when
  results arrive; the deferred first search marks its component too.
- The home page's spinner is a signal.
- Already covered: the charts mark for check in their D3 and Cytoscape handlers, the gene
  list's fetched genes go into its genes model signal, and outputs and the session's
  async pipe notify by themselves.

zone.js leaves the polyfills and the dependencies; the initial bundle is 1.86 MB
(1.90 with zone.js). Tests run in jest-preset-angular's zoneless environment: the two
polling tests use Jest's fake timers instead of fakeAsync (which needs zone.js), and the
analyze tests mark the component before re-rendering after setting its state directly,
as the app's code does.

Checked in Chrome against dev's API (read-only, signed out): a search from the URL, a typed
search, the next page, a gene set's details and genes, refetching genes by another
identifier type, the analyze tool list and the gene set picker's suggestions all render,
with no console errors.
@belkassaby
belkassaby temporarily deployed to jax-cluster-dev-10--dev November 21, 2026 14:08 — with GitHub Actions Inactive
@belkassaby
belkassaby requested a deployment to jax-cluster-dev-10--sqa November 23, 2026 16:22 — with GitHub Actions Waiting
…ion template as expandedrow

PrimeNG 18+ dropped the table's "rowexpansion" template name, so the gene set list's
expansion template was ignored and the chevron toggled nothing. Renamed to "expandedrow",
with a test that expands and collapses a row.
@belkassaby
belkassaby deployed to jax-cluster-dev-10--dev November 23, 2026 16:37 — with GitHub Actions Active
@belkassaby
belkassaby requested a deployment to jax-cluster-dev-10--sqa November 23, 2026 16:49 — with GitHub Actions Waiting

This branch is waiting to be deployed

1 active and 1 waiting deployments
jax-cluster-dev-10--sqa — 4e58bcb9 Waiting Nov 23, 2026 by belkassaby via UI Deploy: SQA / deploy #81
jax-cluster-dev-10--dev — 4e58bcb9 Deployed Nov 23, 2026 by belkassaby via UI Deploy: Dev / deploy #81
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