fix(ripple): prevent layout break when ripple styles excluded and migrate to Web Animations API #16792
+288
−14
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.
Summary
AnimationBuilderto native Web Animations APIProblem
Layout Issue: The ripple directive created a
<span>element that relied on CSS (.igx-ripple__inner) forposition: absolute. When ripple styles were excluded from the theme (common in production optimization), the ripple element became a regular block element, causing the parent button to expand in size.Deprecated APIs:
AnimationBuilderand the entire@angular/animationspackage are deprecated as of Angular v20.2 and will be removed in v23.Solution
1. Fixed Layout Stability
File:
projects/igniteui-angular/directives/src/directives/ripple/ripple.directive.ts:112position: absoluteas an inline style in thesetStyles()method2. Migrated to Web Animations API
File:
projects/igniteui-angular/directives/src/directives/ripple/ripple.directive.ts:150-170Changes:
AnimationBuilder,style, andanimatefrom@angular/animationsimportsprotected builder = inject(AnimationBuilder);this.builder.build([...]).create(rippleElement)with nativerippleElement.animate([...], {...})animation.onDone()toanimation.onfinishanimation.play()call (Web Animations API plays automatically)3. Comprehensive Test Coverage
File:
projects/igniteui-angular/directives/src/directives/ripple/ripple.directive.spec.ts(new)Created test suite with 8 test cases:
All tests use spies on
renderer.setStyleto verify styles are applied correctly.Benefits
@angular/animationsdependency needed for rippleTesting
npm test -- projects/igniteui-angular/directives/rippleAll tests passing:
Breaking Changes
None - all existing ripple functionality and API remain unchanged.
Files Changed
Modified:
projects/igniteui-angular/directives/src/directives/ripple/ripple.directive.tsposition: absolutestyleAnimationBuilderto Web Animations API@angular/animationsCreated:
projects/igniteui-angular/directives/src/directives/ripple/ripple.directive.spec.ts