Integrate CpsRootFontSizeService into components#628
Open
fateeand wants to merge 2 commits into
Open
Conversation
Coverage report for library
Test suite run success869 tests passing in 31 suites. Report generated by 🧪jest coverage report action from 3c06009 |
Playwright test resultsDetails
|
Contributor
There was a problem hiding this comment.
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_SERVICEintoCpsDialogComponent,CpsAutocompleteComponent,CpsButtonToggleComponent, andCpsTooltipDirectiveand 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
CpsButtonToggleComponentspec).
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
virtualScrollItemSizePxis computed once inngOnInit()from_rootFontSizePx. Because_rootFontSizePxis now sourced from a reactiveCpsRootFontSizeServicesignal, root font-size changes at runtime won’t updatevirtualScrollItemSizePx, which can break virtual scroll calculations (e.g.,_scrollVirtualListToIndex). Consider derivingvirtualScrollItemSizePxfrom the signal (e.g., via aneffect/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);
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Integrated
CpsRootFontSizeServiceintoCpsAutocompleteComponent,CpsButtonToggleComponent,CpsDialogComponent, andCpsTooltipDirective, replacing their custom logic, which also lacked support for dynamic root font size changes.Release notes:
CpsRootFontSizeServiceinto components