Skip to content

[6.x] Publish legacy field edits that scripts make without an input event - #20574

Merged
riasvdv merged 1 commit into
6.xfrom
bugfix/legacy-html-control-keyup
Nov 10, 2026
Merged

riasvdv merged 1 commit into
6.xfrom
bugfix/legacy-html-control-keyup

Conversation

@riasvdv

@riasvdv riasvdv commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Description

Legacy field scripts that change a value on keydown and cancel the key fire no input event. Behave.js does this in Simple Text for Backspace, Enter, Tab and auto-closed brackets. craft-legacy-html-control only republished on input, change, jQuery change and submit. Those edits weren't autosaved, and Cmd/Ctrl+S saved the old value. Craft 5's element editor rechecked the form on keyup; the control now does too.

keyup inside <craft-legacy-html-control>
└── handleLegacyChange: serialized inputs ≠ last snapshot?
      ├── no  → nothing (arrow keys, modifiers)
      └── yes → publish('typing')   ← keyup now counts as typing, like input

Evidence

Craft 6 + yii2-adapter host with Simple Text 3.x (craftcms/simple-text#16), Chromium:

Action in a Simple Text field on a canonical entry Before After
Backspace at the end no autosave draft draft with the shortened value
Select all + Backspace no autosave draft draft with the field cleared
( then Enter (Behave auto-close/indent) no autosave draft draft with (\n)
Backspace ×2, then Ctrl+S entry saved with the old value entry saved with the new value
Arrow keys only no draft no draft

Regression test in yii2-adapter/resources/js/legacy-html-control.test.ts:

textarea.value = 'Hell'; dispatch keyup
expect(mutation).toEqual({fields: {notes: 'Hell'}})
  before: expected {} to deeply equal { fields: { notes: 'Hell' } }
  after:  passes (and a keyup with no change publishes nothing)

composer ci passes; adapter JS tests pass (56).

Legacy scripts such as Behave.js (Simple Text) change a value on keydown and
cancel the key, so no input event fires and the edit was neither autosaved nor
saved with Cmd/Ctrl+S. Craft 5's element editor rechecked the form on keyup;
legacy HTML controls now do too, publishing only when a value changed.
@riasvdv
riasvdv merged commit 8f22ea9 into 6.x Nov 10, 2026
17 checks passed
@riasvdv
riasvdv deleted the bugfix/legacy-html-control-keyup branch November 10, 2026 15:56
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