#1843220: Convert form AJAX to new AJAX API broke the automagical #ajax['dialog'] stuff because the page title used to be passed to the front end in a hackish sort-of-way in the old ajax_prepare_response(), and we accidentally dropped it in the new D8 ajax forms.

A temporary measure has been posted to the initial #1843220: Convert form AJAX to new AJAX API issue to fix HEAD for the moment, but I think a better solution is in order. As does the author of the relevant javascript:

    // If the requesting object wanted the response in a dialog, open that
    // dialog. However, a single server response can include multiple insert
    // commands (e.g., one for the primary content and another one for status
    // messages), but we only want to open the dialog once, so we assume that
    // only commands with a title property are dialog eligible.
    // @todo Consider whether this is overloading title inappropriately, and
    //   if so, find another way to determine dialog eligibility.
    if (ajax.dialog && ('title' in response)) {
      var dialogOptions = $.extend({title: response.title}, ajax.dialog);
      var dialog = Drupal.dialog(wrapper, dialogOptions);
      ajax.dialog.modal ? dialog.showModal() : dialog.show();
    }

Comments

Crell’s picture

Related: #1871596: Create a PartialResponse class to encapsulate html-level data [Moving to sandbox]

If that goes in, then controllers can return a strutured object with body and title and eventually other things like new HTML link tags. The AjaxController should be able to dissect that and turn it into the appropriate set of InsertCommand objects, or whatever else we want.

catch’s picture

jibran’s picture

Issue tags:+modal dialog

Tagging.

jessebeach’s picture

Title:Figure out a better way to get the page title to a the modal dialog» Figure out a better way to get the page title to a modal dialog

Removed a spurious "the" from the issue title.

dawehner’s picture

#2100073-11: Convert local_actions to the new local action plugins has some code to use the title resolver introduced in some issue.

mgifford’s picture