From 2ad959e6c84a83352b162d3a788ada1f4b24a9d2 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 20 Feb 2024 16:56:21 +0100 Subject: [PATCH] Prevent closing tags after self-closing JSX tags FIX: Fix a bug that would cause self-closing JSX tags to have another closing tag inserted when typing the final '>'. Closes https://github.com/codemirror/dev/issues/1339 --- src/javascript.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/javascript.ts b/src/javascript.ts index a853d53..15ed570 100644 --- a/src/javascript.ts +++ b/src/javascript.ts @@ -138,7 +138,7 @@ export const autoCloseTags = EditorView.inputHandler.of((view, from, to, text, d } } else if (text == ">") { let openTag = findOpenTag(around) - if (openTag && + if (openTag && openTag.name == "JSXOpenTag" && !/^\/?>|^<\//.test(state.doc.sliceString(head, head + 2)) && (name = elementName(state.doc, openTag, head))) return {range, changes: {from: head, insert: ``}}