Skip to content

Commit 50d31be

Browse files
committed
Merge branch 'master' of https://github.com/isaacphysics/isaac-react-app into feature/nd-coordinate-qs
2 parents 8e4f471 + b718bc8 commit 50d31be

File tree

9 files changed

+40
-9
lines changed

9 files changed

+40
-9
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
REACT_APP_API_VERSION=v3.16.17
1+
REACT_APP_API_VERSION=v3.16.19

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "isaac-react-app",
3-
"version": "3.15.2-SNAPSHOT",
3+
"version": "3.15.4-SNAPSHOT",
44
"private": true,
55
"engines": {
66
"node": ">=18",
@@ -23,7 +23,7 @@
2323
"html-to-text": "^9.0.5",
2424
"identity-obj-proxy": "3.0.0",
2525
"immer": "^9.0.21",
26-
"inequality": "1.1.4",
26+
"inequality": "1.1.5",
2727
"inequality-grammar": "1.3.5",
2828
"isaac-graph-sketcher": "0.13.7",
2929
"js-cookie": "^3.0.5",

src/app/components/content/IsaacSymbolicChemistryQuestion.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,15 @@ const IsaacSymbolicChemistryQuestion = ({doc, questionId, readonly}: IsaacQuesti
161161
const hiddenEditorRef = useRef<HTMLDivElement | null>(null);
162162
const sketchRef = useRef<Inequality | null | undefined>();
163163

164+
const showTextEntry = !readonly && isStaff(user);
165+
164166
useLayoutEffect(() => {
167+
if (!showTextEntry) return; // as the ref will not be defined
168+
169+
if (!isDefined(hiddenEditorRef.current)) {
170+
throw new Error("Unable to initialise inequality; target element not found.");
171+
}
172+
165173
const {sketch, p} = makeInequality(
166174
hiddenEditorRef.current,
167175
100,
@@ -242,7 +250,7 @@ const IsaacSymbolicChemistryQuestion = ({doc, questionId, readonly}: IsaacQuesti
242250
{doc.children}
243251
</IsaacContentValueOrChildren>
244252
</div>
245-
{!readonly && isStaff(user) && <div className="eqn-editor-input">
253+
{showTextEntry && <div className="eqn-editor-input">
246254
<div ref={hiddenEditorRef} className="equation-editor-text-entry" style={{height: 0, overflow: "hidden", visibility: "hidden"}} />
247255
<InputGroup className="my-2 separate-input-group">
248256
<Input type="text" onChange={updateEquation} value={textInput}

src/app/components/content/IsaacSymbolicLogicQuestion.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,13 @@ const IsaacSymbolicLogicQuestion = ({doc, questionId, readonly}: IsaacQuestionPr
136136
const hiddenEditorRef = useRef<HTMLDivElement | null>(null);
137137
const sketchRef = useRef<Inequality | null | undefined>();
138138

139-
useLayoutEffect(() => {
139+
useLayoutEffect(() => {
140+
if (readonly) return; // as the ref won't be defined
141+
142+
if (!isDefined(hiddenEditorRef.current)) {
143+
throw new Error("Unable to initialise inequality; target element not found.");
144+
}
145+
140146
const { sketch, p } = makeInequality(
141147
hiddenEditorRef.current,
142148
100,

src/app/components/content/IsaacSymbolicQuestion.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ const IsaacSymbolicQuestion = ({doc, questionId, readonly}: IsaacQuestionProps<I
166166
const sketchRef = useRef<Inequality | null | undefined>();
167167

168168
useLayoutEffect(() => {
169+
if (readonly) return; // as the ref won't be defined
170+
171+
if (!isDefined(hiddenEditorRef.current)) {
172+
throw new Error("Unable to initialise inequality; target element not found.");
173+
}
174+
169175
const {sketch, p} = makeInequality(
170176
hiddenEditorRef.current,
171177
100,

src/app/components/elements/modals/inequality/InequalityModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ const InequalityModal = ({availableSymbols, logicSyntax, editorMode, close, onEd
331331
const sketch = useRef<Nullable<Inequality>>(null);
332332
const [editorState, setEditorState] = useState<any>({});
333333
useLayoutEffect(() => {
334+
if (!inequalityModalRef) return;
334335
return prepareInequality({
335336
sketch,
336337
inequalityModalRef,

src/app/components/elements/modals/inequality/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,10 @@ interface PrepareInequalityArgs {
690690
setEditorState: (state: any) => void;
691691
}
692692
export function prepareInequality({editorMode, inequalityModalRef, initialEditorSymbols, isTrashActive, sketch, logicSyntax, setEditorState, onEditorStateChange}: PrepareInequalityArgs) {
693+
if (!isDefined(inequalityModalRef.current)) {
694+
throw new Error("Unable to initialise inequality; target element not found.");
695+
}
696+
693697
const { sketch: newSketch, p } = makeInequality(
694698
inequalityModalRef.current,
695699
window.innerWidth,

src/app/components/pages/Equality.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ const Equality = withRouter(({location}: RouteComponentProps<{}, {}, {board?: st
183183
}, [editorSyntax]);
184184

185185
useLayoutEffect(() => {
186+
if (!allowTextInput) return; // as the ref won't be defined
187+
188+
if (!isDefined(hiddenEditorRef.current)) {
189+
throw new Error("Unable to initialise inequality; target element not found.");
190+
}
191+
186192
const {sketch, p} = makeInequality(
187193
hiddenEditorRef.current,
188194
100,

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5941,10 +5941,10 @@ inequality-grammar@1.3.5:
59415941
moo "^0.5.2"
59425942
nearley "^2.20.1"
59435943

5944-
inequality@1.1.4:
5945-
version "1.1.4"
5946-
resolved "https://registry.yarnpkg.com/inequality/-/inequality-1.1.4.tgz#3614933d3c75d246cb30f7aff0c6d3d48bb1093f"
5947-
integrity sha512-Evyixxlw7X1hJtxovTphy7uMGz966p2mfRE0xzV3ffXOPCIZ9HFFF6s+8WPreO9KhgEzdhRG124VtCTKuH8oig==
5944+
inequality@1.1.5:
5945+
version "1.1.5"
5946+
resolved "https://registry.yarnpkg.com/inequality/-/inequality-1.1.5.tgz#b92b769bb5066006aa737eaeb081ce8ca4641264"
5947+
integrity sha512-J/MxmmfI+Wz01O6anvhUOhdKui8Z+Q89sHPSJ/VF+gikTKWdHhUHJY2Naqcow68s4gQPBdeWFIPElu437J04kw==
59485948

59495949
inflight@^1.0.4:
59505950
version "1.0.6"

0 commit comments

Comments
 (0)