Skip to content

[BUGFIX] Keep untouched values when a content element is moved - #158

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

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

Conversation

@Kanti

@Kanti Kanti commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Moving a content element with drag and drop disconnects and reconnects the ve-editable-text elements inside it. connectedCallback parsed the validation attribute into a new object on every connect, so Lit treated validation as changed and updated() normalized and stored the value, although the editor typed nothing. Values that violate the TCA were trimmed or cut, and values shorter than a non-required min were emptied. In 1.10.4, moving a content element never changed field values.

Implemented behavior

  • Lit parses the validation attribute (type: Object), and connectedCallback no longer assigns it.
  • The constructor sets {} as the default for elements without the attribute.

Tests

  • ve-editable-text.test.js (browser): moving the elements with insertBefore, like flipInsertBefore does, keeps untouched values and the parsed validation. This test fails without the fix.
  • The existing parsing tests (upgraded elements, elements inserted after the definition, createElement) pass with Lit's parsing alone.
  • npm run test: 90 passing, npm run lint

Follow-up

Moving an edited field also set valueInitial to the edited value, so the reset button did not restore the initial value afterwards. Fixed in #160.

connectedCallback parsed the validation attribute into a new object on
every connect. Moving a content element with drag and drop reconnects
the editable texts inside, so Lit treated validation as changed and
normalized and stored their values, although the editor typed nothing:
values were trimmed or cut, and values shorter than min were emptied.

Lit already parses the attribute, so connectedCallback no longer
assigns it.
@Kanti
Kanti marked this pull request as ready for review November 9, 2026 14:33
@Kanti
Kanti merged commit 4a98749 into main Nov 9, 2026
33 checks passed
@Kanti
Kanti deleted the bugfix/keep-values-on-dom-move branch November 9, 2026 14:59
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