From f12c96849d0f7fd77f3d34cbfab211fce21d4f42 Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Fri, 12 Aug 2022 18:03:25 +0300
Subject: [PATCH] multiple drop down readonly

---
 .../components/ReadOnlyDropDown.js                 | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/wax-prosemirror-services/src/MultipleDropDownService/components/ReadOnlyDropDown.js b/wax-prosemirror-services/src/MultipleDropDownService/components/ReadOnlyDropDown.js
index 169846680..6fd68ec91 100644
--- a/wax-prosemirror-services/src/MultipleDropDownService/components/ReadOnlyDropDown.js
+++ b/wax-prosemirror-services/src/MultipleDropDownService/components/ReadOnlyDropDown.js
@@ -1,7 +1,6 @@
 /* eslint-disable no-underscore-dangle */
-import React, { useContext, useMemo, useEffect, useState } from 'react';
+import React, { useContext, useEffect, useMemo, useState } from 'react';
 import styled from 'styled-components';
-import { find } from 'lodash';
 import { ReactDropDownStyles } from 'wax-prosemirror-components';
 import { WaxContext } from 'wax-prosemirror-core';
 import { DocumentHelpers } from 'wax-prosemirror-utilities';
@@ -51,6 +50,14 @@ const DropComponent = ({ getPos, node, options }) => {
   } = context;
 
   const customProps = main.props.customValues;
+  const { testMode } = customProps;
+
+  useEffect(() => {
+    const currentOption = node.attrs.options.filter(option => {
+      return option.value === node.attrs.correct;
+    });
+    if (!testMode && currentOption[0]) setSelectedOption(currentOption[0]);
+  }, []);
 
   const onChange = option => {
     const allNodes = getNodes(main);
@@ -66,12 +73,11 @@ const DropComponent = ({ getPos, node, options }) => {
     main.dispatch(tr);
   };
 
-  useEffect(() => {}, []);
-
   const MultipleDropDown = useMemo(
     () => (
       <Wrapper key={uuidv4()}>
         <DropdownStyled
+          disabled={!testMode}
           key={uuidv4()}
           onChange={option => onChange(option)}
           options={options}
-- 
GitLab