Skip to content

[BUGFIX] Keep the initial value when a content element is moved - #160

Merged
Kanti merged 1 commit into
mainfrom
bugfix/keep-initial-value-on-dom-move
Nov 9, 2026
Merged

Kanti merged 1 commit into
mainfrom
bugfix/keep-initial-value-on-dom-move

Conversation

@Kanti

@Kanti Kanti commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Problem

Follow-up to #158. connectedCallback() of ve-editable-text took value and valueInitial from the attributes on every connect. value is reflected (reflect: true), so after an edit the attribute holds the edited value. Moving a content element with drag and drop (flipInsertBefore → insertBefore) disconnects and reconnects the editable texts inside, and valueInitial pointed to the edited value afterwards. The reset button then set the edited value again, and the field stayed changed.

Implemented behavior

  • value and valueInitial are taken from the attributes on the first connect only (!this.hasUpdated). Later connects keep both.
  • Unsaved changes survive moving the element, and the reset button restores the initial value afterwards.

Tests

  • ve-editable-text.test.js (browser):
    • Reset after moving an edited field removes its stored data and shows the initial value again. This test fails without the fix: the store keeps the edited value.
    • An edited, unsaved field keeps its value in the store and in the slot after moving. The bug only affected the initial value, so this test passes without the fix as well; it makes sure the fix keeps the edits.
    • The existing test for untouched values shares the new helpers for rendering and moving the elements.
  • npm run test: 94 passing, npm run lint

connectedCallback took value and valueInitial from the attributes on
every connect. value is reflected, so after an edit the attribute holds
the edited value. Moving a content element with drag and drop
reconnects the editable texts inside, and valueInitial pointed to the
edited value afterwards: the reset button set the edited value again,
and the field stayed changed.

value and valueInitial are taken from the attributes on the first
connect only.
@Kanti
Kanti merged commit f74a484 into main Nov 9, 2026
33 checks passed
@Kanti
Kanti deleted the bugfix/keep-initial-value-on-dom-move branch November 9, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant