diff --git a/templates/shared/combomarkdowneditor.tmpl b/templates/shared/combomarkdowneditor.tmpl
index 42840a3825..c7ad7cc1de 100644
--- a/templates/shared/combomarkdowneditor.tmpl
+++ b/templates/shared/combomarkdowneditor.tmpl
@@ -52,13 +52,13 @@ Template Attributes:
-
+
-
{{ctx.Locale.Tr "loading"}}
diff --git a/tests/e2e/markdown-editor.test.e2e.ts b/tests/e2e/markdown-editor.test.e2e.ts
index acc7a00a24..ded3e94706 100644
--- a/tests/e2e/markdown-editor.test.e2e.ts
+++ b/tests/e2e/markdown-editor.test.e2e.ts
@@ -674,3 +674,41 @@ test('Monospace button aria-label', async ({page}) => {
await monospaceButton.click();
await assertAriaLabel(enabled);
});
+
+test('Persistent monospace preference across multiple editors', async ({page}) => {
+ // Load page with editor
+ const response = await page.goto('/user2/repo1/issues/1');
+ expect(response?.status()).toBe(200);
+
+ // Toggle monospace preference ON in case it is not
+ const monospaceButton = page.locator('.markdown-switch-monospace').first();
+ const isMonospaceButtonChecked = await monospaceButton.getAttribute('aria-checked') === 'true';
+ if (!isMonospaceButtonChecked) {
+ await monospaceButton.click();
+ }
+
+ // Open a second editor (by clicking "Edit" in the context menu of a message)
+ const openSecondEditor = async () => {
+ const contextMenu = page.locator('.timeline-item [aria-label="Comment menu"]:has(.edit-content)').first();
+ const editButton = contextMenu.getByRole('menuitem').getByText('Edit').first();
+ await contextMenu.click();
+ await editButton.click();
+ };
+ await openSecondEditor();
+
+ // Check if monospaced class is applied to all visible editors
+ const checkMonospacePreferenceAcrossEditors = async () => {
+ const editors = page.locator('.markdown-text-editor');
+ for (const editor of await editors.all()) {
+ await expect(editor).toHaveClass(/tw-font-mono/);
+ }
+ };
+ await checkMonospacePreferenceAcrossEditors();
+
+ // Reloads page to check persitance of monospace preference
+ const response2 = await page.goto('/user2/repo1/issues/1');
+ expect(response2?.status()).toBe(200);
+
+ await openSecondEditor();
+ await checkMonospacePreferenceAcrossEditors();
+});
diff --git a/web_src/js/features/comp/ComboMarkdownEditor.js b/web_src/js/features/comp/ComboMarkdownEditor.js
index b42d054ae9..3182ac0078 100644
--- a/web_src/js/features/comp/ComboMarkdownEditor.js
+++ b/web_src/js/features/comp/ComboMarkdownEditor.js
@@ -78,6 +78,11 @@ class ComboMarkdownEditor {
this.textarea.addEventListener('input', (e) => this.options?.onContentChanged?.(this, e));
this.applyEditorHeights(this.textarea, this.options.editorHeights);
+ const monospaceEnabled = localStorage?.getItem('markdown-editor-monospace') === 'true';
+ if (monospaceEnabled) {
+ this.textarea.classList.add('tw-font-mono');
+ }
+
if (this.textarea.getAttribute('data-disable-autosize') !== 'true') {
this.textareaAutosize = autosize(this.textarea, {viewportMarginBottom: 130});
}
@@ -173,7 +178,6 @@ class ComboMarkdownEditor {
});
const monospaceButton = this.container.querySelector('.markdown-switch-monospace');
- const monospaceEnabled = localStorage?.getItem('markdown-editor-monospace') === 'true';
const monospaceText = monospaceButton.getAttribute(monospaceEnabled ? 'data-disable-text' : 'data-enable-text');
monospaceButton.setAttribute('data-tooltip-content', monospaceText);
monospaceButton.setAttribute('aria-label', monospaceText);