Skip to content

fix(waapi): commit multi-word final keyframes to inline style - #75

Open
JonathonRP wants to merge 1 commit into
mainfrom
jonathonrp-fix-waapi-camelcase-style-commit
Open

fix(waapi): commit multi-word final keyframes to inline style#75
JonathonRP wants to merge 1 commit into
mainfrom
jonathonrp-fix-waapi-camelcase-style-commit

Conversation

@JonathonRP

@JonathonRP JonathonRP commented Aug 2, 2026

Copy link
Copy Markdown
Owner

The bug

setStyle in packages/motion-start/src/animation/animators/waapi/utils/style.ts committed the final keyframe with element.style.setProperty(name, String(value)).

CSSOM's setProperty lowercases the property name it is given but does not convert camelCase to kebab-case, so setProperty("clipPath", ...) becomes "clippath", which is not a real property, and the declaration is silently discarded.

NativeAnimation.onFinish writes the final keyframe with setValue and then immediately cancels the WAAPI animation. When the write is a no-op, cancelling drops the element straight back to its pre-animation value — exactly the flash the commit exists to prevent. clipPath, backgroundColor, borderRadius and every other multi-word member of acceleratedValues take the WAAPI path, so all of them were affected.

It went unnoticed because the only coverage was opacity, a single-word property whose name survives setProperty unchanged.

The fix

Assign through the camelCase indexer, matching upstream framer-motion v11.11.11: element.style[name as MotionStyleKey] = value as never. CSS custom properties (--*) still go through setProperty, since the indexer does not work for those.

Tests

Added two regression tests alongside the existing opacity cases in waapi/__tests__/animate-style.spec.ts, covering clipPath and backgroundColor and asserting the final keyframe lands in inline style after the animation finishes and is cancelled. Both fail against the old implementation (expected '' to be 'inset(10%)') and pass with the fix; the existing opacity coverage stays green.

vitest --run on packages/motion-start: 620 passed. Two unrelated specs (reorder-production-ssr, package-imports) hit the 30s timeout under parallel load on this machine and pass in isolation.

A patch changeset is included.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed WAAPI animations so multi-word CSS properties retain their correct final values, including clipPath, backgroundColor, and borderRadius.
    • Improved handling of CSS custom properties during animation completion.
  • Tests

    • Added coverage for completed single-value and multi-value animations involving multi-word CSS properties.

setProperty lowercases but does not kebab-case the property name, so committing the final keyframe of clipPath, backgroundColor and every other multi-word acceleratedValue was silently dropped and the element snapped back on cancel. Assign through the camelCase indexer like upstream, keeping CSS custom properties on setProperty.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Aug 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 138d5e2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
motion-start Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The WAAPI style utility now directly assigns standard CSS properties and retains setProperty for custom properties. Tests cover completed clipPath and backgroundColor animations. A patch changeset documents the fix.

Changes

WAAPI CSS assignment

Layer / File(s) Summary
Style assignment and validation
packages/motion-start/src/animation/animators/waapi/utils/style.ts, packages/motion-start/src/animation/animators/waapi/__tests__/animate-style.spec.ts, .changeset/wild-poems-commit.md
setStyle directly assigns standard CSS properties and uses setProperty for custom properties. Tests verify final clipPath and backgroundColor values. A patch changeset records the correction.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the fix for committing multi-word WAAPI keyframes to inline styles.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jonathonrp-fix-waapi-camelcase-style-commit

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Aug 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/motion-start@75

commit: 138d5e2

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/motion-start/src/animation/animators/waapi/utils/style.ts`:
- Around line 16-20: Normalize custom-property names in setCSSVar so names
already beginning with “--” are not prefixed again. Update the completion path
used by NativeAnimation while preserving normal CSS property handling and
ensuring values are written to the intended custom property when WAAPI is
unavailable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b745aa45-6505-40bd-b9ad-8a225f4d6039

📥 Commits

Reviewing files that changed from the base of the PR and between 0adcef2 and 138d5e2.

📒 Files selected for processing (3)
  • .changeset/wild-poems-commit.md
  • packages/motion-start/src/animation/animators/waapi/__tests__/animate-style.spec.ts
  • packages/motion-start/src/animation/animators/waapi/utils/style.ts

Comment on lines +16 to +20
if (name.startsWith('--')) {
element.style.setProperty(name, String(value));
} else {
element.style[name as MotionStyleKey] = value as never;
}

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Files:"
git ls-files | rg 'packages/motion-start/src/animation/animators/waapi/(style|NativeAnimation)\.ts$' || true

echo
echo "style.ts outline and contents:"
if [ -f packages/motion-start/src/animation/animators/waapi/utils/style.ts ]; then
  ast-grep outline packages/motion-start/src/animation/animators/waapi/utils/style.ts || true
  cat -n packages/motion-start/src/animation/animators/waapi/utils/style.ts
fi

echo
echo "NativeAnimation.ts relevant sections:"
if [ -f packages/motion-start/src/animation/animators/waapi/NativeAnimation.ts ]; then
  wc -l packages/motion-start/src/animation/animators/waapi/NativeAnimation.ts
  ast-grep outline packages/motion-start/src/animation/animators/waapi/NativeAnimation.ts || true
  sed -n '1,190p' packages/motion-start/src/animation/animators/waapi/NativeAnimation.ts | cat -n
fi

echo
echo "search setCSSVar/setStyle usages:"
rg -n "setCSSVar|setStyle|valueName|style\.setProperty|custom property|--foo|----foo" packages/motion-start/src/animation/animators/waapi packages/motion-start/src -S || true

echo
echo "test files mentioning custom property setCSSVar:"
rg -n "setCSSVar|--\w+|custom" packages/motion-start -g '*test*' -g '*spec*' -g '*.test.ts' -g '*.test.tsx' -S || true

Repository: JonathonRP/motion-start

Length of output: 27835


Normalize CSS custom-property names before setCSSVar.

NativeAnimation passes the full custom-property name such as --css-var with valueName.startsWith('--'). setCSSVar prefixes another --, so completion writes ----css-var when WAAPI is unavailable. Accept names as --css-var and avoid double-prefixing in setCSSVar, or strip one prefix before the call.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/motion-start/src/animation/animators/waapi/utils/style.ts` around
lines 16 - 20, Normalize custom-property names in setCSSVar so names already
beginning with “--” are not prefixed again. Update the completion path used by
NativeAnimation while preserving normal CSS property handling and ensuring
values are written to the intended custom property when WAAPI is unavailable.

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.

2 participants