Skip to content

Bug: form_observer Stimulus controller throws "jQuery is not defined" (unsaved-changes warning never runs) #3702

Open

Description

@nakamura196

app/javascript/spotlight/admin/form_observer.js is still written as a jQuery plugin, but jQuery is no longer bundled with Blacklight 8 / Spotlight 5. The controller therefore throws on every page that loads it, and the "you have unsaved changes" beforeunload guard never takes effect.

What happens

Browsing the admin screens as an exhibit admin, the console shows:

Uncaught ReferenceError: jQuery is not defined
    at .../assets/spotlight/admin/form_observer-<digest>.js:67

Why

The file wraps its plugin in an IIFE that is invoked with jQuery, and connect() then uses $:

https://github.com/projectblacklight/spotlight/blob/main/app/javascript/spotlight/admin/form_observer.js

;(function ($, _) {
  ...
})(jQuery)          // ← ReferenceError: jQuery is not defined

export default class {
  connect() {
    var serializedForm = $.SerializedForm()
    $(window).on("beforeunload page:before-change turbolinks:before-visit turbo:before-visit", ...)
  }
}

Nothing else on the page defines jQuery, so the module fails at evaluation time.

Impact

Cosmetically nothing is broken — pages render fine — which is why it is easy to miss. But the feature this controller exists for (warning a curator who navigates away from a form with unsaved changes) is silently inoperative.

Environment

  • spotlight bd8d5b7 (5.3.0), blacklight 8.12.3, Rails 8.1
  • Reproduced on the generated test app with both importmap and the default asset setup.

Also noticed nearby

On /:exhibit_id/appearance/edit, the masthead cropper raises Invalid LatLng object: (-5, NaN) from Leaflet when the exhibit's masthead is an external IIIF image. Filed here only as a note — happy to open a separate issue if useful.

Activity

  1. jcoyne commented on Aug 30, 2026

    @jcoyne
    Member

    Maybe #3678 should be merged now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions