Opening dialog via AJAX casts dialogOptions values to strings

Created on 16 November 2018, over 5 years ago
Updated 30 January 2023, over 1 year ago

Problem/Motivation

This took a while to track down and may not seem like that big of a bug at first, but it's a fairly major one if your site relies heavily on dialogs/modals.

The easiest way to explain the issue is to use the closeOnEscape boolean value as an example.

When this option is passed via AJAX, it passes the actual value of false. This value is subsequently converted into a string representation due to how PHP works when it reaches DialogRenderer or ModalRenderer and becomes "false".

Thus, when it's actually passed back to JavaScript as AJAX commands in a response to actually open said dialog/modal, its actual value (a string) is treated as a positive value. This is because most code, if not all, expects this to be a boolean and treats it as such with statements like if (options.closeOnEscape).

For more details, see #2978392: Mapped option closeOnEscape doesn't work as expected β†’ .

Proposed resolution

Filter, sanitize and cast passed dialogOptions to proper values.

Remaining tasks

  • Create test(s)

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Needs work

Version

9.5

Component
AjaxΒ  β†’

Last updated 18 minutes ago

Created by

πŸ‡ΊπŸ‡ΈUnited States markhalliwell

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot β†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

Production build 0.69.0 2024