Skip to content

Commit aaa2205

Browse files
committed
Refreshed markdown cm instance layout on size change
Intended to fix positioning quirks caused by changing codemirror instance size when you have lines that wrap and cause line height changes. Often caused by editor toolbox expand/collapse. This adds a debounced resize observer to refresh editor layout on size change. Also tweaks toolbox expand/collapse to more consistently set aria attribute. For #3186
1 parent 4aed3f8 commit aaa2205

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

resources/js/components/editor-toolbox.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ class EditorToolbox {
4141
if (cName === tabName) this.contentElements[i].style.display = 'block';
4242
}
4343

44-
if (openToolbox) this.elem.classList.add('open');
44+
if (openToolbox && !this.elem.classList.contains('open')) {
45+
this.toggle();
46+
}
4547
}
4648

4749
}

resources/js/components/markdown-editor.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ class MarkdownEditor {
112112
if (scrollText) {
113113
this.scrollToText(scrollText);
114114
}
115+
116+
// Refresh CodeMirror on container resize
117+
const resizeDebounced = debounce(() => code.updateLayout(this.cm), 100, false);
118+
const observer = new ResizeObserver(resizeDebounced);
119+
observer.observe(this.elem);
115120
}
116121

117122
// Update the input content and render the display.

0 commit comments

Comments
 (0)