MohammadYounes / MohammadYounes/AlertifyJS

prefers-reduced-motion: reduce causes crash in custom dialogs if reopened quickly

Open
#274 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2.1k
Forks
294
PR merge metrics
No merged PRs in 30d

Description

Whether you set alertify.defaults.transitionOff = true, alertify.defaults.transition = null or use chromium devtools to "Emulate CSS prefers-reduced-motion: reduce" (by using the command palette, Ctrl+Shift+P) all these result in the same crash.

I have reproduced the issue in a jsfiddle here: https://jsfiddle.net/m9o3sed0/8/

Video from jsfiddle reproduction

The crash happens when opening, closing and reopening the dialog in quick succession (like an automated browser test). It doesn't happen unless transitions/animations are somehow disabled.

It also doesn't happen unless you set closeEvent.cancel = true (like in the jsfiddle) and use .destroy() to close it instead.

The crash happens here (it might be a little annoying to get a stack trace from jsfiddle, but you should be able to do it in devtools):
https://github.com/MohammadYounes/AlertifyJS/blob/8dde6f105c62fa144b7bffd3377401e4b843b9b8/src/js/dialog/transition.js#L11
Because instance.__internal === undefined.

The use case for calling .destroy() in this manner instead of letting the default behaviour (close event?) close the dialog is that we want to open another nested dialog and wait for that one to .destroy() the first one.

This bug is reproducible all the way back to alertify v1.5.0, when .destroy() was introduced.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/js/dialog/transition.js at the reported line and reproduce the jsfiddle scenario with transitions disabled or prefers-reduced-motion enabled. Exercise rapid open, close, destroy, and reopen calls with closeEvent.cancel set; done means the sequence completes without accessing undefined dialog internals or crashing.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
accessibility, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.