File tree Expand file tree Collapse file tree
xblocks_contrib/problem/assets Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,6 +91,23 @@ data-url='/problem/quiz/'> \
9191 it ( "bind the math input" , function ( ) {
9292 expect ( $ ( "input.math" ) ) . toHandleWith ( "keyup" , this . problem . refreshMath ) ;
9393 } ) ;
94+
95+ it ( "does not bind refreshMath to formula equation inputs" , function ( ) {
96+ // Formula-equation inputs are exclusively managed by formula_equation_preview.js.
97+ $ . ajax . and . callFake ( function ( settings ) {
98+ if ( settings . url . match ( / .+ \/ p r o b l e m _ g e t $ / ) ) {
99+ settings . success ( {
100+ html : readFixtures ( "problem_content.html" ) +
101+ '<section class="formulaequationinput"><input type="text" id="input_formula_1" />' +
102+ '<div id="input_formula_1_preview" class="equation"></div></section>' ,
103+ } ) ;
104+ }
105+ } ) ;
106+ this . problem = new Problem ( mockRuntime , $ ( ".xblock-student_view" ) ) ;
107+ MathJax . typesetClear . calls . reset ( ) ;
108+ $ ( ".formulaequationinput input" ) . trigger ( "keyup" ) ;
109+ expect ( MathJax . typesetClear ) . not . toHaveBeenCalled ( ) ;
110+ } ) ;
94111 } ) ;
95112
96113 describe ( "bind_with_custom_input_id" , function ( ) {
Original file line number Diff line number Diff line change @@ -119,9 +119,10 @@ Problem.prototype.bind = function () {
119119 this . submitAnswersAndSubmitButton ( true ) ;
120120 }
121121 Collapsible . setCollapsibles ( this . el ) ;
122- this . $ ( "input.math, .formulaequationinput input" ) . keyup ( this . refreshMath ) ;
122+ // Formula equation inputs use formula_equation_preview.js to manage their server-rendered preview.
123+ this . $ ( "input.math" ) . keyup ( this . refreshMath ) ;
123124 if ( isMathJaxTypesetReady ( ) ) {
124- this . $ ( "input.math, .formulaequationinput input " ) . each ( function ( index , element ) {
125+ this . $ ( "input.math" ) . each ( function ( index , element ) {
125126 return MathJax . startup . promise . then ( ( ) => that . refreshMath ( null , element ) ) ;
126127 } ) ;
127128 }
You can’t perform that action at this time.
0 commit comments