Skip to content

Commit 7b388b6

Browse files
committed
#netpyne-149 validation for inputs in bubble tutorial
1 parent ba6a9d4 commit 7b388b6

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

webapp/components/general/TutorialBubble.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const TutorialBubble = ({
7272
const nextTourStep = steps[requestedTourStep];
7373
const { target: nextTarget } = nextTourStep || { target: undefined };
7474

75-
const { target, title, content } = tourStep;
75+
const { target, validation, title, content } = tourStep;
7676

7777
const DOMtarget = getDOMTarget(target, tourStep);
7878
const nextDOMtarget = getDOMTarget(nextTarget, nextTourStep);
@@ -117,6 +117,17 @@ const TutorialBubble = ({
117117
stopTutorial(event);
118118
};
119119

120+
const isNextDisabled = (validationTarget, step, isDisabled) => {
121+
if (validationTarget) {
122+
const validationDOMTarget = getDOMTarget(validationTarget, undefined);
123+
if (validationDOMTarget && validationDOMTarget.checkVisibility()) {
124+
return !isDisabled;
125+
}
126+
return true;
127+
}
128+
return !isDisabled;
129+
};
130+
120131
if (currentTourStep === requestedTourStep) {
121132
tutorialTarget.current = null;
122133
}
@@ -195,7 +206,7 @@ const TutorialBubble = ({
195206
variant="contained"
196207
color="primary"
197208
onClick={listen}
198-
disabled={!nextIsVisible}
209+
disabled={isNextDisabled(validation, tourStep, isNextDisabled)}
199210
>
200211
Next
201212
</Button>

webapp/redux/reducers/data/tutorial_steps.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const tutorial_steps = [
2222
},
2323
{
2424
target: '#cellRuleName',
25+
validation: 'input[value="pyr"]',
2526
title: 'Cell Customization',
2627
content: (
2728
<p>Rename the cell type: "pyr" for pyramidal.</p>

0 commit comments

Comments
 (0)