Problem/Motivation

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork flag-3555233

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

ivnish created an issue. See original summary.

  • ivnish committed 4c5d5e5a on 5.x
    [#3555233] feat: Use AJAX submit when confirmation form is modal
    
    By:...
ivnish’s picture

Assigned: ivnish » Unassigned
Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

tomdearden’s picture

Hi,

I think maybe this change doesn't take proper account of all the possible configurations that a Flag can have. Specifically, an AJAX error is thrown when flagging a node for 'dialog'-style flags.

Steps to reproduce

  • Set up a basic Drupal site using `drupal/recommended-project` eg. as here https://docs.ddev.com/en/latest/users/quickstart/#drupal
  • Create a new 'Content' Flag type, choosing 'Dialog' as the 'Form behavior'
  • Create and publish a new Basic Page node
  • View the new node
  • Click the 'Flag this item' link
  • Click the 'Create flagging' button in the dialog that appears

The flag state changes on the page but the dialog box doesn't close and an AJAX error is visible in the browser console:

`An error occurred during the execution of the Ajax response: Error: cannot call methods on dialog prior to initialization; attempted to call method 'close'`

I don't understand the lifecycle of the dialog component well enough to propose a proper resolution, but a quick-and-dirty patch to check for a behavior type of 'modal' as well as for an XMLHttpRequest context when deciding whether to add the `#ajax` key to the submit button render array has stopped the issue occurring for me (albeit at the expense of a page reload vs. the nicer intended AJAX behaviour).

ivnish’s picture

Hi! Could you create a new issue?

tomdearden’s picture

Of course - no problem. Here it is:

https://www.drupal.org/project/flag/issues/3625010