Skip to content

Commit

Permalink
Refresh the code mirror window when its containing div resizes.
Browse files Browse the repository at this point in the history
This fixes issue openwebwork#2218.
  • Loading branch information
drgrice1 authored and somiaj committed Sep 30, 2023
1 parent 41082c7 commit d813eb3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions htdocs/js/PGCodeMirror/pgeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@
= CodeMirror.fromTextArea(document.querySelector('.codeMirrorEditor'), options);
cm.setSize('100%', '550px');

// Refresh the CodeMirror instance anytime the containing div resizes so that if line wrapping changes,
// the mouse cursor will still go to the correct place when the user clicks on the CodeMirror window.
new ResizeObserver(() => cm.refresh()).observe(document.querySelector('.CodeMirror'));

const currentThemeFile = localStorage.getItem('WW_PGEditor_selected_theme') ?? 'default';
const currentThemeName = await loadConfig(currentThemeFile);
cm.setOption('theme', currentThemeName);
Expand Down

0 comments on commit d813eb3

Please sign in to comment.