Skip to content

Old metabox handling and JS updating text fields #3975

@maxxwv

Description

@maxxwv

Issue Overview

When inserting a value via JavaScript into a text field in a form in the editor-meta-boxes-area div in Gutenberg doesn't trigger the changedMetaBoxState() function to mark the metabox-contained data dirty.

In this instance, I've created a gallery CPT - a meta box contains thumbnails of any previously selected images, add/edit/remove buttons, and a hidden field that contains a json-encoded string of selected image IDs. I use the wp.media.frames.file_frame update event to update the content of the hidden field with the IDs of the selected images. However, isDirty is not set to true when the value is updated. If I type directly into the field, the value of isDirty is updated as expected.

Steps to Reproduce (for bugs)

  1. Create a metabox (old-school style) with a text field.
  2. Update the value of the field via JavaScript.

Expected Behavior

isDirty is set to true and the value of the field is saved on Update.

Current Behavior

Nothing. IsDirty is not set to true and the editor doesn't know it needs to save the metabox data. Again, if you type directly into the field everything works as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Meta BoxesA draggable box shown on the post editing screen

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions