fix: not call destroy on destroyed step#3455
Conversation
|
Someone is attempting to deploy a commit to the shipshapecode Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughA new ChangesNull-checking type guard and step initialization
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~4 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed: private package registry requires authentication. Disable ESLint in CodeRabbit settings or use public packages. 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. Comment |
There was a problem hiding this comment.
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 `@shepherd.js/src/step.ts`:
- Line 450: The teardown at line 450 assigns `undefined` to this.el, but the
getElement() method's contract and type signature indicate it returns null for
destroyed steps. Revert line 450 to assign null instead of undefined to maintain
the documented contract. Then update the guard logic in _setupElements() to
check if this.el is either null or undefined (treating both as "not mounted") to
handle any edge cases where undefined might be present from other code paths.
🪄 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
Run ID: 82196bde-61fb-41d7-8d5f-b3b9cfd8b837
📒 Files selected for processing (2)
shepherd.js/src/step.tsshepherd.js/test/unit/step.spec.js
98217ff to
c7a9cc6
Compare
Currently on function
_setupElementsof step, the destroy function is called ifthis.elis undefined but the destroy method setthis.elto null. So functiondestroyis called also on destroyed element which trigger unnecessary 'destroy' event.Another possible change would be to change the condition in
_setupElementsto check ifthis.elis either undefined or null.This is linked with reported issue #3443
Summary by CodeRabbit
New Features
isNulltype-guard utility for reliably detectingnullvalues.Bug Fixes
nullvsundefined, and to avoid redundant teardown when a step has already been destroyed.Tests
destroyis later replaced.