Skip to content

perf(Presence): skip work for bubbled animation events - #2839

Merged
zernonia merged 2 commits into
unovue:v2from
guillemservera:perf/presence-ignore-bubbled-animation-events
Aug 3, 2026
Merged

zernonia merged 2 commits into
unovue:v2from
guillemservera:perf/presence-ignore-bubbled-animation-events

Conversation

@guillemservera

@guillemservera guillemservera commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Linked issue

Closes #2838

Type of change

  • Documentation
  • Bug fix
  • Enhancement
  • New feature
  • Chore
  • Breaking change

Description

animationend and animationcancel bubble from descendants. Presence was
calling getAnimationName(node.value), and therefore getComputedStyle,
before checking whether the event originated from its own host element. The
result was discarded for descendant events because both behavior branches
already required event.target === node.value.

I moved that target check to an early return. Events from the Presence host
retain the same behavior, while descendant events no longer trigger
unnecessary style reads. This also aligns handleAnimationEnd with the
existing target guard in handleAnimationStart.

I added a regression test with a direct-event positive control before
asserting that a bubbled descendant event does not read the Presence host
styles.

Screenshots

Not applicable.

Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly. Not applicable: this is an
    internal, behavior-preserving performance change with no public API changes.

Validation

  • pnpm --filter reka-ui exec vitest run src/Presence/Presence.test.ts
  • pnpm exec eslint packages/core/src/Presence/usePresence.ts packages/core/src/Presence/Presence.test.ts
  • pnpm --filter reka-ui type-check
  • pnpm --filter reka-ui build

Summary by CodeRabbit

  • Bug Fixes
    • Fixed presence animations completing incorrectly when animation events bubble up from descendant elements.
    • Ensured only animation events from the tracked element determine animation completion, improving transition reliability.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3081af0a-467c-4282-83a3-0500f8469e63

📥 Commits

Reviewing files that changed from the base of the PR and between aa5a0e9 and 3dc34da.

📒 Files selected for processing (1)
  • packages/core/src/Presence/Presence.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core/src/Presence/Presence.test.ts

📝 Walkthrough

Walkthrough

Presence now rejects bubbled descendant animation events before reading computed styles. A regression test covers direct host events and descendant events.

Changes

Presence animation event handling

Layer / File(s) Summary
Filter animation events and validate style reads
packages/core/src/Presence/usePresence.ts, packages/core/src/Presence/Presence.test.ts
handleAnimationEnd returns when the event target is not the tracked node. Tests verify host events read computed styles and descendant events do not.

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: skipping work for bubbled animation events in Presence.
Linked Issues check ✅ Passed The changes add the target guard, preserve host-event behavior, and provide regression coverage for direct and bubbled events [#2838].
Out of Scope Changes check ✅ Passed The implementation and tests remain within the linked issue scope for Presence animation event handling [#2838].
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@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

🧹 Nitpick comments (1)
packages/core/src/Presence/Presence.test.ts (1)

150-157: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use @testing-library/vue for the added component test.

The test adds another mount call from @vue/test-utils. The path guideline requires @testing-library/vue for tests in this directory. Use the required renderer and query helpers for this regression test.

As per coding guidelines, tests matching packages/core/src/**/*.test.ts must use Vitest, jsdom, @testing-library/vue, and vitest-axe.

🤖 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/core/src/Presence/Presence.test.ts` around lines 150 - 157, Update
the added component test around the mount call to use `@testing-library/vue`
instead of `@vue/test-utils`, including its render and query helpers. Preserve the
regression scenario and ensure the test remains compatible with the existing
Vitest, jsdom, and vitest-axe setup.

Source: Coding guidelines

🤖 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/core/src/Presence/Presence.test.ts`:
- Around line 149-180: Move the Presence component mount into the existing
try/finally block so any exception during mount still reaches the cleanup path.
Keep getComputedStyleSpy restoration in finally, ensuring the global spy is
always restored while preserving the current test assertions and unmount
cleanup.

---

Nitpick comments:
In `@packages/core/src/Presence/Presence.test.ts`:
- Around line 150-157: Update the added component test around the mount call to
use `@testing-library/vue` instead of `@vue/test-utils`, including its render and
query helpers. Preserve the regression scenario and ensure the test remains
compatible with the existing Vitest, jsdom, and vitest-axe setup.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ede024a3-8378-4ede-8283-2b54a37cb2a9

📥 Commits

Reviewing files that changed from the base of the PR and between c6e1460 and aa5a0e9.

📒 Files selected for processing (2)
  • packages/core/src/Presence/Presence.test.ts
  • packages/core/src/Presence/usePresence.ts

@pkg-pr-new

pkg-pr-new Bot commented Aug 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/reka-ui@2839

commit: 3dc34da

@zernonia
zernonia merged commit 85895b2 into unovue:v2 Aug 3, 2026
7 checks passed
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.

[Performance]: Presence reads styles for bubbled descendant animation events

2 participants