Skip to content

fix(notifications): guard against NaN/empty transitionDuration and transitionEasing in animate()#20057

Closed
wadimsewo wants to merge 1 commit into
filamentphp:4.xfrom
wadimsewo:fix/notification-animate-nan-duration
Closed

fix(notifications): guard against NaN/empty transitionDuration and transitionEasing in animate()#20057
wadimsewo wants to merge 1 commit into
filamentphp:4.xfrom
wadimsewo:fix/notification-animate-nan-duration

Conversation

@wadimsewo

@wadimsewo wadimsewo commented Jun 18, 2026

Copy link
Copy Markdown

What is the problem?

When rapidly triggering actions that send notifications (4–5 times in quick succession), Livewire commits pile up. During these rapid commits, window.getComputedStyle(el).transitionDuration and transitionTimingFunction can return empty strings — causing parseFloat('') to yield NaN and leaving the easing as "".

Passing these invalid values to the Web Animations API throws:

TypeError: Failed to execute 'animate' on 'Element': duration must be non-negative or auto
TypeError: Failed to execute 'animate' on 'Element': Easing may not be the empty string

This crashes the Alpine.js component and blocks all subsequent Livewire requests, causing the UI to fully hang until a page reload.

What is the solution?

Apply fallback guards at the point of assignment in init():

  • parseFloat(...) * 1000 || 0 — falls back to 0 when the computed value is NaN
  • transitionTimingFunction || 'ease' — falls back to 'ease' when the computed value is an empty string

Steps to reproduce

  1. Open any Filament page with a table action that sends a notification on completion
  2. Submit the action 4–5 times rapidly without waiting for notifications to dismiss
  3. Observe the TypeError in the browser console and the UI hanging

…ansitionEasing

When rapidly triggering actions that send notifications, Livewire commits
pile up. During these rapid commits, `getComputedStyle` can return empty
strings for `transitionDuration` and `transitionTimingFunction`, causing
`parseFloat('')` to yield `NaN` and leaving the easing as `""`.

Passing these to the Web Animations API throws:

  TypeError: Failed to execute 'animate' on 'Element':
    duration must be non-negative or auto
  TypeError: Failed to execute 'animate' on 'Element':
    Easing may not be the empty string

This crashes Alpine.js and blocks subsequent Livewire requests, causing
the UI to hang until a page reload.

Fix: apply fallback guards at the point of assignment in `init()`:
- `parseFloat(...) * 1000 || 0` for duration
- `transitionTimingFunction || 'ease'` for easing
@wadimsewo wadimsewo force-pushed the fix/notification-animate-nan-duration branch from 3653811 to 8d6eddd Compare June 18, 2026 12:43

@people-sea people-sea left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks more like a fallback than a root-cause fix. I tried several ways to reproduce this locally, but couldn’t trigger the error naturally.

If you’re seeing this in a real app, could you share the exact reproduction steps, along with a screenshot or video of the error? That would help us understand what’s causing the invalid transition values and fix the underlying issue, instead of adding a guard that may hide it.
Thanks!

@wadimsewo

Copy link
Copy Markdown
Author

I tried to reproduce this with a fresh installation but wasn't able to. I then noticed that the Livewire JS files were outdated — after publishing them with php artisan livewire:publish --assets, the error no longer occurred. It did seem to be connected to DB notifications as well. Since I wasn't able to reliably reproduce the issue, I'll close this PR for now. Thanks!

@wadimsewo wadimsewo closed this Jun 19, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Done in Roadmap Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants