@@ -1203,6 +1203,16 @@ export class Menu {
12031203 */
12041204 protected setAssistiveMml ( mml : boolean ) {
12051205 this . document . options . enableAssistiveMml = mml ;
1206+ if ( mml ) {
1207+ this . noRerender ( ( ) => {
1208+ if ( this . settings . speech ) {
1209+ this . menu . pool . lookup ( 'speech' ) . setValue ( false ) ;
1210+ }
1211+ if ( this . settings . braille ) {
1212+ this . menu . pool . lookup ( 'braille' ) . setValue ( false ) ;
1213+ }
1214+ } ) ;
1215+ }
12061216 if ( ! mml || MathJax . _ ?. a11y ?. [ 'assistive-mml' ] ) {
12071217 this . rerender ( ) ;
12081218 } else {
@@ -1236,6 +1246,11 @@ export class Menu {
12361246 protected setSpeech ( speech : boolean ) {
12371247 this . enableAccessibilityItems ( 'Speech' , speech ) ;
12381248 this . document . options . enableSpeech = speech ;
1249+ if ( speech && this . settings . assistiveMml ) {
1250+ this . noRerender ( ( ) =>
1251+ this . menu . pool . lookup ( 'assistiveMml' ) . setValue ( false )
1252+ ) ;
1253+ }
12391254 if ( ! speech || MathJax . _ ?. a11y ?. explorer ) {
12401255 this . rerender ( STATE . COMPILED ) ;
12411256 } else {
@@ -1249,6 +1264,11 @@ export class Menu {
12491264 protected setBraille ( braille : boolean ) {
12501265 this . enableAccessibilityItems ( 'Braille' , braille ) ;
12511266 this . document . options . enableBraille = braille ;
1267+ if ( braille && this . settings . assistiveMml ) {
1268+ this . noRerender ( ( ) =>
1269+ this . menu . pool . lookup ( 'assistiveMml' ) . setValue ( false )
1270+ ) ;
1271+ }
12521272 if ( ! braille || MathJax . _ ?. a11y ?. explorer ) {
12531273 this . rerender ( STATE . COMPILED ) ;
12541274 } else {
@@ -1381,24 +1401,24 @@ export class Menu {
13811401 * Reset all menu settings to the (page) defaults
13821402 */
13831403 protected resetDefaults ( ) {
1384- Menu . loading ++ ; // pretend we're loading, to suppress rerendering for each variable change
1385- const pool = this . menu . pool ;
1386- const settings = this . defaultSettings ;
1387- for ( const name of Object . keys ( settings ) as ( keyof MenuSettings ) [ ] ) {
1388- const variable = pool . lookup ( name ) ;
1389- if ( variable ) {
1390- if ( variable . getValue ( ) !== settings [ name ] ) {
1391- variable . setValue ( settings [ name ] as string | boolean ) ;
1392- const item = ( variable as any ) . items [ 0 ] ;
1393- if ( item ) {
1394- item . executeCallbacks_ ( ) ;
1404+ this . noRerender ( ( ) => {
1405+ const pool = this . menu . pool ;
1406+ const settings = this . defaultSettings ;
1407+ for ( const name of Object . keys ( settings ) as ( keyof MenuSettings ) [ ] ) {
1408+ const variable = pool . lookup ( name ) ;
1409+ if ( variable ) {
1410+ if ( variable . getValue ( ) !== settings [ name ] ) {
1411+ variable . setValue ( settings [ name ] as string | boolean ) ;
1412+ const item = ( variable as any ) . items [ 0 ] ;
1413+ if ( item ) {
1414+ item . executeCallbacks_ ( ) ;
1415+ }
13951416 }
1417+ } else if ( Object . hasOwn ( this . settings , name ) ) {
1418+ ( this . settings as any ) [ name ] = settings [ name ] ;
13961419 }
1397- } else if ( Object . hasOwn ( this . settings , name ) ) {
1398- ( this . settings as any ) [ name ] = settings [ name ] ;
13991420 }
1400- }
1401- Menu . loading -- ;
1421+ } ) ;
14021422 this . rerender ( STATE . COMPILED ) ;
14031423 }
14041424
@@ -1694,6 +1714,17 @@ export class Menu {
16941714 }
16951715 }
16961716
1717+ protected noRerender ( exec : ( ) => void ) {
1718+ Menu . loading ++ ; // pretend we're loading, to suppress rerendering durring exec() call
1719+ try {
1720+ exec ( ) ;
1721+ Menu . loading -- ;
1722+ } catch ( err ) {
1723+ Menu . loading -- ; // make sure this resets if there is an error
1724+ throw err ;
1725+ }
1726+ }
1727+
16971728 /**
16981729 * Copy the serialzied MathML to the clipboard
16991730 */
0 commit comments