Skip to content

Integrate CpsRootFontSizeService into components#628

Open
fateeand wants to merge 2 commits into
masterfrom
583-integrate-cpsrootfontsizeservice-into-components
Open

Integrate CpsRootFontSizeService into components#628
fateeand wants to merge 2 commits into
masterfrom
583-integrate-cpsrootfontsizeservice-into-components

Conversation

@fateeand
Copy link
Copy Markdown
Collaborator

Integrated CpsRootFontSizeService into CpsAutocompleteComponent, CpsButtonToggleComponent, CpsDialogComponent, and CpsTooltipDirective, replacing their custom logic, which also lacked support for dynamic root font size changes.


Release notes:

  • Integrate CpsRootFontSizeService into components

@fateeand fateeand requested a review from korel-san as a code owner May 19, 2026 13:15
Copilot AI review requested due to automatic review settings May 19, 2026 13:15
@fateeand fateeand linked an issue May 19, 2026 that may be closed by this pull request
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 19, 2026

Coverage report for library

St.
Category Percentage Covered / Total
🔴 Statements 41.66% 2888/6933
🔴 Branches 35.79% 1208/3375
🔴 Functions 40.84% 553/1354
🔴 Lines 42.32% 2705/6392

Test suite run success

869 tests passing in 31 suites.

Report generated by 🧪jest coverage report action from 3c06009

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 19, 2026

Playwright test results

passed  70 passed

Details

stats  70 tests across 4 suites
duration  2 minutes, 9 seconds
commit  3c06009
info  For details, download the Playwright report

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 standardizes how root font size is obtained across UI components/directives by integrating CpsRootFontSizeService (via CPS_ROOT_FONT_SIZE_SERVICE) and removing per-component DOM getComputedStyle(...).fontSize logic, with corresponding test updates/additions.

Changes:

  • Inject CPS_ROOT_FONT_SIZE_SERVICE into CpsDialogComponent, CpsAutocompleteComponent, CpsButtonToggleComponent, and CpsTooltipDirective and replace local root-font-size reads with service access.
  • Remove component/directive init-time root font-size detection where replaced by the service.
  • Update/add unit tests to provide a mock root font size service (including a new CpsButtonToggleComponent spec).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
projects/cps-ui-kit/src/lib/services/cps-dialog/internal/components/cps-dialog/cps-dialog.component.ts Use root font size service instead of local cached value.
projects/cps-ui-kit/src/lib/services/cps-dialog/internal/components/cps-dialog/cps-dialog.component.spec.ts Provide mock root font size service for dialog tests.
projects/cps-ui-kit/src/lib/directives/cps-tooltip/cps-tooltip.directive.ts Use root font size service; remove OnInit root font-size initialization.
projects/cps-ui-kit/src/lib/directives/cps-tooltip/cps-tooltip.directive.spec.ts Provide mock root font size service for tooltip tests.
projects/cps-ui-kit/src/lib/components/cps-button-toggle/cps-button-toggle.component.ts Use root font size service and remove platform/browser-specific font-size read.
projects/cps-ui-kit/src/lib/components/cps-button-toggle/cps-button-toggle.component.spec.ts Add unit tests for button toggle behavior (incl. equal-width calculations).
projects/cps-ui-kit/src/lib/components/cps-autocomplete/cps-autocomplete.component.ts Use root font size service and remove init-time computed-style font-size read.
projects/cps-ui-kit/src/lib/components/cps-autocomplete/cps-autocomplete.component.spec.ts Provide mock root font size service for autocomplete tests.
Comments suppressed due to low confidence (1)

projects/cps-ui-kit/src/lib/components/cps-autocomplete/cps-autocomplete.component.ts:483

  • virtualScrollItemSizePx is computed once in ngOnInit() from _rootFontSizePx. Because _rootFontSizePx is now sourced from a reactive CpsRootFontSizeService signal, root font-size changes at runtime won’t update virtualScrollItemSizePx, which can break virtual scroll calculations (e.g., _scrollVirtualListToIndex). Consider deriving virtualScrollItemSizePx from the signal (e.g., via an effect/computed) or recalculating it whenever the root font size changes.
  ngOnInit() {
    this.virtualScrollItemSizePx =
      this._rootFontSizePx * VIRTUAL_SCROLL_ITEM_SIZE_REM;
    this.virtualListHeightRem =
      VIRTUAL_SCROLL_ITEM_SIZE_REM * VIRTUAL_SCROLL_MAX_VISIBLE_ITEMS;
    this.cvtWidth = convertSize(this.width);

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.

Integrate CpsRootFontSizeService into components

2 participants