Problem/Motivation
Opening /admin/config/content/diff/fields triggers an uncaught JavaScript exception from core's Field UI behavior:
TypeError: Cannot read properties of undefined (reading 'field-display-overview')
at Object.attach (core/modules/field_ui/js/field_ui.js:107:41)
The exception occurs on initial page load and after AJAX updates. The page should load and update without JavaScript exceptions.
Reproduced on an existing site running Drupal 10.6.22 and Diff 2.1.1. This is yet untested on Drupal 11, but the code of the field_ui.js and the diff module seems to have not changed between versions.
Steps to reproduce
- On a site with Diff enabled, sign in as an administrator and open the browser's developer console.
- Visit
/admin/config/content/diff/fields. - Observe the exception above.
- Open a field plugin's settings with its Edit button, then click Cancel. The same exception recurs after AJAX replaces the table.
Observed functional impact
Plugin/widget selection, Edit, Update, Cancel, and Save all worked despite the exception. No functional failures were observed even for some other fields on the edit form, but not all possible field plugins were exhaustively tested. I tested an Address field (module version 2.0.6) and it seemed okay.
Proposed resolution
Investigate how Diff uses the core Field UI display behavior on Diff Fields configuration forms. What we see is that FieldsSettingsForm::buildForm() builds a regular HTML table with ID field-display-overview and attaches field_ui/drupal.field_ui, but it lacks #tabledrag configuration. Then, core Drupal.fieldUIOverview.attach() accesses Drupal.tableDrag[table.id]. But there weren't any draggable rows or drag handles, and Drupal.tableDrag was undefined.
This suggests a Diff integration problem, not a core Field UI problem, despite the error surfacing an error in field_ui.js.
Proposed resolution is to avoid invoking the table-drag-dependent behavior on this table while preserving the required styling and plugin controls.
There is a semi-related issue in Diff module issue queue #3462560: A legacy form #ajax method value causes JavaScript error at Fields Settings page on Drupal 11 RC1 which fixed a different error on field edit form pages: $wrapper[method] is not a function. That issue doesn't appear to interfere here and the replaceWith change is present in latest diff version 2.1.1.
Remaining tasks
- Confirm a minimal reproduction.
- Implement the appropriate form/library change.
- Add regression coverage for page load and AJAX updates without exceptions, while preserving settings persistence.
- Review and test the fix.
User interface changes
None. There should be no intended visible changes by fixing this issue.
Introduced terminology
None.
API changes
None intended.
Data model changes
None intended.
Release notes snippet
Not required for this minor bug report.
AI disclosure: AI assisted with investigating the source, running browser automation, and drafting this report.
Comments
Comment #2
jwilson3Comment #3
jwilson3