Skip to content

H5P Editor submit handler now checks if an event exists during trigger to...

Problem/Motivation

H5P Editor widget loses data during multi-value field "Add Another" and "Remove" codepaths.

Steps to reproduce

Pre-conditions

  • A content type with a field using the H5P Editor widget, with no limit. ("Multi H5P")

Steps

  1. Create a new "Multi H5P" node.
  2. Fill in the title for the node.
  3. Select an H5P type from the list. ("True/False" is a simple one for testing.)
  4. Click "Add another item".
  • Before fixes: the first H5P Editor in the list would fully reset.
  • After fixes: the first H5P Editor recreates itself with the chosen type.
  1. The same can be observed for filling values in the H5P Editor, like "title" and "question".

Solution

  • H5P Editor submit handler now checks if an event exists during trigger before trying to prevent default (which only occurs during form submit, and not during add/remove).
  • The submit handler now uses a similar check to determine whether to use the h5peditor vendor files' getParam functions or to extract the value directly.
    • These include input field validation which is not desired during add/remove.
    • Behaves similar to other multi-value field adds/removes.

Additional considerations

Recommend testing the single-H5P Editor experience as well to confirm no side-effects of the changes have made this experience poor.

Closes #3281356

Merge request reports

Loading