Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 296282

Leave preview popup on ajax call

$
0
0

Problem/Motivation

When using the Preview on same page feature for content editing, Drupal displays a confirmation modal when navigating away from the preview. However, this modal is also triggered during in-page AJAX interactions (e.g., filtering, autosubmit forms, autocomplete selections), causing confusion and unnecessary interruptions to the user experience.

This is especially disruptive when working with features like view mode switching, inline form updates, or autocomplete fields that are AJAX-driven but don’t constitute actual navigation away from the page.

Steps to reproduce

  1. Enable content preview for a node type.
  2. Start creating/editing content and preview it.
  3. Trigger an AJAX action, such as:
  4. - Using an autocomplete field.
    - Changing a view mode that autosubmits.

  5. Observe the "Leave preview?" modal incorrectly appears, despite not leaving the page.

Proposed resolution

This patch updates the nodePreviewDestroyLinks and nodePreviewSwitchViewMode behaviors to properly:

  • Detect and handle AJAX requests via ajaxComplete, setting a hasAjaxRun flag.
  • Suppress the leave-preview modal for AJAX-driven interactions
  • Prevent false-positive triggers of the modal during expected UI events.

Remaining tasks

  • Review JavaScript logic for robustness.
  • Confirm patch fixes the issue across different browsers.
  • Confirm behavior works with modal and non-modal previews.

Viewing all articles
Browse latest Browse all 296282

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>