User tests: Successful: Unsuccessful:
Pull Request resolves #40641 .
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
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
The CodeMirror editor is initialized only once per textarea
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
| Status | New | ⇒ | Pending |
| Category | ⇒ | JavaScript Repository NPM Change |
| Labels |
Added:
NPM Resource Changed
PR-5.4-dev
|
||
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.
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 😃