NPM Resource Changed PR-5.4-dev Pending

User tests: Successful: Unsuccessful:

avatar adarshdubey03
adarshdubey03
5 Apr 2026

Pull Request resolves #40641 .

  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

This fixes an issue where the CodeMirror editor is duplicated when subform rows are reordered as it adds a minimal guard using the JoomlaEditor registry to prevent duplicate initialization

Testing Instructions

  1. Set CodeMirror as the default editor
  2. Create or edit an item that contains a subform field with an editor field
  3. Go to articles -> new -> feilds and add multiple subform rows
  4. Drag and reorder the rows

Actual result BEFORE applying this Pull Request

Each time a subform row is reordered, a new CodeMirror editor instance is created for the same textarea, resulting in duplicated editors in the ui

Expected result AFTER applying this Pull Request

The CodeMirror editor is initialized only once per textarea

Link to documentations

Please select:

  • Documentation link for guide.joomla.org:

  • No documentation changes for guide.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar adarshdubey03 adarshdubey03 - open - 5 Apr 2026
avatar adarshdubey03 adarshdubey03 - change - 5 Apr 2026
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 5 Apr 2026
Category JavaScript Repository NPM Change
avatar Fedik
Fedik - comment - 5 Apr 2026

Sorry the fix is incorrect.
Hint: It even not really on Codemirror side (however it affects Codemirror itself due to how it work).

I give you a time to find a real reason 😃

avatar adarshdubey03 adarshdubey03 - change - 6 Apr 2026
Labels Added: NPM Resource Changed PR-5.4-dev
avatar adarshdubey03
adarshdubey03 - comment - 6 Apr 2026

Thanks for the hint @Fedik . The issue turned out to be in how the editor handles its lifecycle during subform row reordering. so the element is actually moved in the dom (not recreated), which triggers disconnectedCallback() and then connectedCallback(). The current code treats this as a real removal and destroys the editor, so when it reconnects a new instance gets created, which causes duplicated editors. so the new fix is to delay the destruction in disconnectedCallback() and only destroy if the element is actually removed, while cancelling that delay if it reconnects ,so the editor instance is preserved.

Add a Comment

Login with GitHub to post a comment