Skip to content

Fix errors - #36890

Merged
nicobytes merged 31 commits into
mainfrom
nicobytes/35930-migrate-angular-22-fix
Aug 5, 2026
Merged

Fix errors#36890
nicobytes merged 31 commits into
mainfrom
nicobytes/35930-migrate-angular-22-fix

Conversation

@nicobytes

@nicobytes nicobytes commented Aug 5, 2026

Copy link
Copy Markdown
Member

This pull request improves the thumbnail field handling in the template creation/editing UI and refines the binary upload button implementation. The main changes enhance accessibility, ensure correct behavior when no thumbnail is provided, and simplify the file input logic.

Template Thumbnail Field Improvements:

  • Added an explicit id and name="thumbnail" to the thumbnail input field for better accessibility and form integration (dot-template-props.component.html, dot-template-thumbnail-field.component.html). [1] [2]
  • Updated the writeValue method in DotTemplateThumbnailFieldComponent to properly handle empty or null IDs by resetting state and avoiding unnecessary service calls (dot-template-thumbnail-field.component.ts).
  • Added and updated tests to verify that no fetch or state changes occur when the thumbnail ID is empty, improving test coverage and reliability (dot-template-thumbnail-field.component.spec.ts). [1] [2]

Binary Upload Button Refactoring:

  • Removed the redundant fileInput property and componentDidLoad lifecycle method, replacing direct references with a new getFileInput() helper for safer DOM access (dot-binary-upload-button.tsx). [1] [2]
  • Updated file selection and change handling to use the new helper, ensuring the component gracefully handles cases where no file is selected.

Fix #35930

nicobytes and others added 29 commits July 17, 2026 12:18
… ESLint configurations

- Updated Node.js version from 22.15.0 to 22.22.3 in multiple configuration files, including `.github/copilot-instructions.md` and `pom.xml`.
- Consolidated ESLint configuration rules across various applications and libraries for consistency and clarity, ensuring all relevant files adhere to the same standards.
- Removed unnecessary imports and streamlined coverage collection settings in Jest configuration files.

This update enhances compatibility and maintains code quality across the project.
…onfig, and improve frontend onboarding documentation
…urations

- Cleaned up ESLint configuration files across multiple applications and libraries by removing unnecessary imports related to FlatCompat.
- This change streamlines the ESLint setup and enhances consistency across the project.
…ate tests

- Refactored the `ContentTypesLayoutComponent` to use signals for managing the add-to-menu state, replacing the previous boolean flag.
- Updated the HTML template to reflect the new signal-based logic for displaying the add-to-menu component.
- Adjusted unit tests in `content-types-layout.component.spec.ts` to accommodate the changes in state management and component interactions.
- Modified the `DotAddToMenuComponent` to emit events correctly, ensuring proper functionality in the updated context.
- Enhanced the `dot-content-types.component.html` to align with the new event handling for the add-to-menu feature.
…functionality

- Added tests to verify that timeline items are correctly keyed by inode and bundleId.
- Implemented checks to ensure the timeline key updates appropriately when version lists are swapped.
- Introduced mock data for DotCMSContentletVersion and DotPushPublishHistoryItem to facilitate testing.
- Enhanced the DotHistoryTimelineListComponent to utilize a stable identity function for timeline items, improving key generation logic.
…nit tests

- Adjusted the HTML structure in `content-types-layout.component.html` for better readability and consistency.
- Updated the unit tests in `content-types-layout.component.spec.ts` to streamline component overrides and enhance clarity.
- Made minor formatting changes in `dot-history-timeline-list.component.spec.ts` to improve code organization and maintainability.
Restores nx format:check compliance so Initial Artifact Build passes in CI.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Updates the pinned nx version and regenerates the pnpm lockfile to match, pulling in the corresponding transitive dependency graph changes for @nx/* packages.
- Aligns @angular/* packages with the latest 22.1.x patch release
- Follows the @nx/* toolchain bump to 23.1.1 across all Nx plugins
- Updates ng-packagr and related devkit/build-angular versions to match
…lar 22 across multiple applications

- Updated tsconfig.app.json files in dotcdn, dotcms-binary-field-builder, dotcms-block-editor, and dotcms-ui to include a TODO comment regarding the re-enabling of strictTemplates once Angular 22 template errors are resolved.
Moved workflow-actions-dialog.spec.ts from edit-content/sidebar to edit-content/workflows to better reflect the test's subject area.
- Angular 21/22's tighter change detection left the form hidden
  because the async role fetch in ngOnInit updated state without
  triggering a CD pass, leaving `@if (form)` unrendered inside the
  dialog's appendTo="body" view.
- Inject ChangeDetectorRef and call detectChanges() after setup to
  force the view to render once roles resolve.
Replace inline `import('@playwright/test').Page` type expressions with the named `Page` import for readability.
…ail handling

- Added an `id` attribute to the thumbnail field in the template properties form for better accessibility.
- Updated the thumbnail field component to handle empty values correctly, preventing unnecessary data fetches and ensuring the loading state is managed properly.
- Enhanced tests to verify the new behavior of the thumbnail field when receiving empty values.

This change improves the user experience and ensures the component behaves as expected in various scenarios.
Copilot AI lite review requested due to automatic review settings August 5, 2026 09:43
@claude

claude Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Claude finished @nicobytes's task in 1m 4s —— View job


PR Review

Reviewed the diff against origin/main. The three prior Copilot findings are all correctly resolved, and I found no new issues.

Resolved

  • dot-binary-upload-button.tsx:70getFileInput() now uses querySelector<HTMLInputElement>(...), so the return type matches the declared HTMLInputElement | null. No compile mismatch.
  • dot-binary-upload-button.tsx:74fileChangeHandler reads from (event.target as HTMLInputElement).files?.[0] instead of re-querying the DOM. getFileInput() is now only used on the Browse-click path. Optional chaining + if (!file) return correctly no-ops when nothing is selected.
  • dot-template-props.component.html:31 — Label now uses for="dot-thumbnail", which matches the file input's id. Verified the chain: dot-binary-file name="thumbnail"dot-binary-upload-button name="thumbnail"id={getId("thumbnail")} = "dot-thumbnail" (utils.tsx:100). All components render in light DOM (no shadow: true), so the external <label for> associates with the real <input type="file">.

Notes (non-blocking)

  • dot-template-thumbnail-field.component.ts:110writeValue(id: string | null) short-circuiting on empty/null is correct: it resets asset/loading and skips the fetch, avoiding a getDataById call with an empty id. Test coverage for both the empty and populated paths is present (dot-template-thumbnail-field.component.spec.ts:117, :366).
  • getFileInput() returning null is handled with ?.click() on the Browse path; worst case is a no-op click, which is safe.

No issues found. The PR looks good to merge.

· nicobytes/35930-migrate-angular-22-fix

@github-actions github-actions Bot added the Area : Frontend PR changes Angular/TypeScript frontend code label Aug 5, 2026

Copilot AI left a comment

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.

Pull request overview

This pull request updates the template thumbnail field used in the template create/edit UI and refactors the binary upload button web component to better handle empty values and simplify file input access.

Changes:

  • Adds name="thumbnail" wiring for the template thumbnail binary field and updates writeValue to short-circuit/reset state when the ID is empty.
  • Extends unit tests to ensure no fetch happens when the thumbnail ID/form value is empty.
  • Refactors the Stencil upload button to query the file input on demand and no-op when no file is selected.

Reviewed changes

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

Show a summary per file
File Description
core-web/libs/dotcms-webcomponents/src/components/contenttypes-fields/dot-binary-file/components/dot-binary-upload-button/dot-binary-upload-button.tsx Refactors file input access and file-selection handling in the upload button component.
core-web/apps/dotcms-ui/src/app/portlets/dot-templates/dot-template-create-edit/dot-template-props/dot-template-thumbnail-field/dot-template-thumbnail-field.component.ts Updates CVA writeValue to reset state when provided an empty/null thumbnail ID.
core-web/apps/dotcms-ui/src/app/portlets/dot-templates/dot-template-create-edit/dot-template-props/dot-template-thumbnail-field/dot-template-thumbnail-field.component.spec.ts Adds tests ensuring empty IDs don’t trigger fetches or disabled state changes.
core-web/apps/dotcms-ui/src/app/portlets/dot-templates/dot-template-create-edit/dot-template-props/dot-template-thumbnail-field/dot-template-thumbnail-field.component.html Sets name="thumbnail" on the dot-binary-file used for thumbnail uploads.
core-web/apps/dotcms-ui/src/app/portlets/dot-templates/dot-template-create-edit/dot-template-props/dot-template-props.component.html Attempts to improve label association for the thumbnail field by adding an id to the thumbnail field component.

@nicobytes

Copy link
Copy Markdown
Member Author

Confirmed on the two Medium notes for dot-binary-upload-button:

  1. Selector change (input[type="file"]) — Safe. This component’s render() has always put the file input directly under <Host> (no nested dot-label). The only consumer is dot-binary-file, which wraps the upload button in a parent dot-label, so the old this.el.querySelector('dot-label input') could never find it (descendant-only). E2E also queries input/button on the host directly. No other consumer depended on a dot-label structure inside this component.

  2. getFileInput()?.files[0] — Agreed; optional chaining + if (!file) return is intentional. The previous cached this.fileInput path would throw on Browse when the reference was null.

No further code change needed for these notes.

…accessibility

- Changed the `for` attribute of the thumbnail label from `thumbnail` to `dot-thumbnail` for improved clarity.
- Removed the `id` attribute from the `dot-template-thumbnail-field` component to streamline the HTML structure.
- Ensured the component maintains proper form control binding with `formControlName="image"`.

This update enhances the accessibility and consistency of the template properties form.
@mergify

mergify Bot commented Aug 5, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@nicobytes
nicobytes added this pull request to the merge queue Aug 5, 2026
Merged via the queue into main with commit d54c969 Aug 5, 2026
51 checks passed
@nicobytes
nicobytes deleted the nicobytes/35930-migrate-angular-22-fix branch August 5, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Safe To Rollback Area : Frontend PR changes Angular/TypeScript frontend code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Migrate Angular 21 → Angular 22 (TypeScript 6) across the core-web Nx workspace

3 participants