Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/math-inline/src/__tests__/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { shallowChild } from '@pie-lib/pie-toolbox/test-utils';
import { Feedback } from '@pie-lib/pie-toolbox/render-ui';
import { CorrectAnswerToggle } from '@pie-lib/pie-toolbox/correct-answer-toggle';
import SimpleQuestionBlock from '../simple-question-block';
import { mount } from 'enzyme';

const Mathquill = require('@pie-framework/mathquill');

Expand Down Expand Up @@ -97,6 +98,7 @@ describe('Math-Inline Main', () => {
},
},
showCorrect: false,
tooltipContainerRef: expect.any(Object),
});

expect(Mathquill.getInterface().registerEmbed).toHaveBeenCalled();
Expand Down Expand Up @@ -211,6 +213,7 @@ describe('Math-Inline Main', () => {
},
},
showCorrect: false,
tooltipContainerRef: expect.any(Object),
});
});

Expand All @@ -237,6 +240,7 @@ describe('Math-Inline Main', () => {
},
},
showCorrect: false,
tooltipContainerRef: expect.any(Object),
});
});

Expand All @@ -262,6 +266,7 @@ describe('Math-Inline Main', () => {
},
},
showCorrect: false,
tooltipContainerRef: expect.any(Object),
});

const newProps = { ...defaultProps };
Expand Down Expand Up @@ -289,6 +294,7 @@ describe('Math-Inline Main', () => {
},
},
showCorrect: false,
tooltipContainerRef: expect.any(Object),
});
});
});
Expand Down
7 changes: 6 additions & 1 deletion packages/math-inline/src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export class Main extends React.Component {
session: { ...props.session, answers },
activeAnswerBlock: '',
showCorrect: this.props.model.config.alwaysShowCorrect || false,
tooltipContainerRef: React.createRef(),
};
}

Expand Down Expand Up @@ -525,7 +526,7 @@ export class Main extends React.Component {

render() {
const { model, classes } = this.props;
const { activeAnswerBlock, showCorrect, session } = this.state;
const { activeAnswerBlock, showCorrect, session, tooltipContainerRef } = this.state;
const {
config,
correctness,
Expand Down Expand Up @@ -622,6 +623,7 @@ export class Main extends React.Component {

{responseType === ResponseTypes.advanced && (
<div
ref={tooltipContainerRef}
className={cx(classes.expression, {
[classes.incorrect]: !emptyResponse && !correct && !showCorrect,
[classes.correct]: !emptyResponse && (correct || showCorrect),
Expand All @@ -639,6 +641,9 @@ export class Main extends React.Component {
tooltip: classes.keypadTooltip,
popper: classes.keypadTooltipPopper,
}}
PopperProps={{
container: tooltipContainerRef?.current || undefined,
}}
title={Object.keys(session.answers).map(
(answerId) =>
(answerId === activeAnswerBlock && !(showCorrect || disabled) && (
Expand Down