Skip to content

Instantly share code, notes, and snippets.

Created November 1, 2017 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/eae614f5c7be9e8de15c46aed31f503e to your computer and use it in GitHub Desktop.
Save anonymous/eae614f5c7be9e8de15c46aed31f503e to your computer and use it in GitHub Desktop.
From ba845a53e48615839bbac7dfef785011aa0f2163 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Mathieu=20Gagne=CC=81?= <mgagne@iweb.com>
Date: Tue, 11 Jul 2017 15:48:19 -0400
Subject: [PATCH] Find latest index before splicing non-ready steps in wizard
When splicing more than 1 step, the index of the following steps
are shifted. This means index won't be valid anymore.
This change makes it so the index of the step to be removed is determined
against the current $scope.steps to avoid stalled index.
Change-Id: Iabfdd3445117b898251782969c3d915b802f440e
---
horizon/static/framework/widgets/wizard/wizard.controller.js | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/horizon/static/framework/widgets/wizard/wizard.controller.js b/horizon/static/framework/widgets/wizard/wizard.controller.js
index e9f586e..e31d2fd 100644
--- a/horizon/static/framework/widgets/wizard/wizard.controller.js
+++ b/horizon/static/framework/widgets/wizard/wizard.controller.js
@@ -192,7 +192,12 @@
step.ready = true;
},
function() {
- $scope.steps.splice(index, 1);
+ for (var i = $scope.steps.length - 1; i >= 0; i--) {
+ if ($scope.steps[i].id === step.id) {
+ $scope.steps.splice(i, 1);
+ break;
+ }
+ }
}
);
}
--
1.9.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment