Skip to content
Snippets Groups Projects
Commit 79ce2a24 authored by chris's avatar chris
Browse files

fix: dropdown value

parent 6132737b
No related branches found
No related tags found
1 merge request!360fix: dropdown value
......@@ -28,10 +28,19 @@ class MultipleChoiceQuestion extends Tools {
get active() {
return state => {
return Commands.isParentOfType(
state,
state.config.schema.nodes.multiple_choice,
);
if (
Commands.isParentOfType(
state,
state.config.schema.nodes.multiple_choice,
) ||
Commands.isParentOfType(
state,
state.config.schema.nodes.question_node_multiple,
)
) {
return true;
}
return false;
};
}
......
......@@ -28,10 +28,19 @@ class MultipleChoiceSingleCorrectQuestion extends Tools {
get active() {
return state => {
return Commands.isParentOfType(
state,
state.config.schema.nodes.multiple_choice_single_correct,
);
if (
Commands.isParentOfType(
state,
state.config.schema.nodes.multiple_choice_single_correct,
) ||
Commands.isParentOfType(
state,
state.config.schema.nodes.question_node_multiple_single,
)
) {
return true;
}
return false;
};
}
......
......@@ -28,10 +28,16 @@ class TrueFalseQuestion extends Tools {
get active() {
return state => {
return Commands.isParentOfType(
state,
state.config.schema.nodes.true_false,
);
if (
Commands.isParentOfType(state, state.config.schema.nodes.true_false) ||
Commands.isParentOfType(
state,
state.config.schema.nodes.question_node_true_false,
)
) {
return true;
}
return false;
};
}
......
......@@ -28,10 +28,19 @@ class TrueFalseSingleCorrectQuestion extends Tools {
get active() {
return state => {
return Commands.isParentOfType(
state,
state.config.schema.nodes.true_false_single_correct,
);
if (
Commands.isParentOfType(
state,
state.config.schema.nodes.true_false_single_correct,
) ||
Commands.isParentOfType(
state,
state.config.schema.nodes.question_node_true_false_single,
)
) {
return true;
}
return false;
};
}
......
......@@ -173,12 +173,12 @@ const QuestionEditorComponent = ({ node, view, getPos }) => {
}, []);
const dispatchTransaction = tr => {
const outerTr = context.view.main.state.tr;
context.view.main.dispatch(outerTr.setMeta('outsideView', questionId));
const { state, transactions } = questionView.state.applyTransaction(tr);
context.updateView({}, questionId);
questionView.updateState(state);
context.updateView({}, questionId);
if (!tr.getMeta('fromOutside')) {
const outerTr = view.state.tr;
const offsetMap = StepMap.offset(getPos() + 1);
for (let i = 0; i < transactions.length; i++) {
const { steps } = transactions[i];
......@@ -186,7 +186,7 @@ const QuestionEditorComponent = ({ node, view, getPos }) => {
outerTr.step(steps[j].map(offsetMap));
}
if (outerTr.docChanged)
context.view.main.dispatch(outerTr.setMeta('outsideView', questionId));
view.dispatch(outerTr.setMeta('outsideView', questionId));
}
};
......
......@@ -73,9 +73,12 @@ const DropComponent = ({ title, view, tools }) => {
];
useEffect(() => {
setLabel('Multiple Question Types');
dropDownOptions.forEach((option, i) => {
if (option.item.active(main.state)) {
setLabel(option.label);
setTimeout(() => {
setLabel(option.label);
});
}
});
}, [activeViewId]);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment