From 34c37bc914c0f5f1670b54fe2babcd3ddcc7fc40 Mon Sep 17 00:00:00 2001 From: jacobtoppm Date: Fri, 11 Nov 2022 17:13:16 +0000 Subject: [PATCH] Stop comments being added on inline panels - They do not have stable ids when models are not persisted to the database - Fixes #9641 This feature should was enabled unintentionally. It would be great to add the ability to comment on child models in the future, but just like ListBlock before the addition of ids, we need a stable way to calculate the id to attach a comment before we can do this. This is a problem we'll need to solve - potentially via a uuid field on the model to identify models that haven't yet been saved to the database outside revisions. --- CHANGELOG.txt | 1 + client/src/entrypoints/admin/comments.js | 12 +++++++----- docs/releases/4.2.md | 9 +++++++++ .../admin/templates/wagtailadmin/shared/field.html | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 1e05ab69c3..f91acd86bb 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -24,6 +24,7 @@ Changelog * Fix: Ensure there is a visual difference of 'active/current link' vs normal links in Windows high-contrast mode (Mohammad Areeb) * Fix: Avoid issues where trailing whitespace could be accidentally removed in translations for new page & snippet headers (Florian Vogt) * Fix: Make sure minimap error indicators follow the minimap scrolling (Thibaud Colas) + * Fix: Remove the ability to view or add comments to `InlinePanel` inner fields to avoid lost or incorrectly linked comments (Jacob Topp-Mugglestone) * Docs: Add custom permissions section to permissions documentation page (Dan Hayden) * Docs: Add documentation for how to get started with contributing translations for the Wagtail admin (Ogunbanjo Oluwadamilare) * Docs: Officially recommend `fnm` over `nvm` in development documentation (LB (Ben) Johnston) diff --git a/client/src/entrypoints/admin/comments.js b/client/src/entrypoints/admin/comments.js index 76f979e08f..e3020e868f 100644 --- a/client/src/entrypoints/admin/comments.js +++ b/client/src/entrypoints/admin/comments.js @@ -19,7 +19,7 @@ window.comments = (() => { function getContentPath(fieldNode) { // Return the total contentpath for an element as a string, in the form field.streamfield_uid.block... - if (fieldNode.closest('data-contentpath-disabled')) { + if (fieldNode.closest('[data-contentpath-disabled]')) { return ''; } let element = fieldNode.closest('[data-contentpath]'); @@ -163,10 +163,14 @@ window.comments = (() => { throw new MissingElementError(annotationTemplateNode); } this.annotationTemplateNode = annotationTemplateNode; - this.shown = false; + this.updateVisibility(false); } register() { + if (!this.contentpath) { + // The widget has no valid contentpath, skip subscriptions + return undefined; + } const { selectEnabled } = commentApp.selectors; const initialState = commentApp.store.getState(); let currentlyEnabled = selectEnabled(initialState); @@ -300,9 +304,7 @@ window.comments = (() => { commentAdditionNode: buttonElement, annotationTemplateNode: document.querySelector('#comment-icon'), }); - if (widget.contentpath) { - widget.register(); - } + widget.register(); }; // Our template node may not exist yet - let's hold off until comments are loaded and enabled onNextEnable(initWidget); diff --git a/docs/releases/4.2.md b/docs/releases/4.2.md index 6cee6841e7..00fe0a5693 100644 --- a/docs/releases/4.2.md +++ b/docs/releases/4.2.md @@ -36,6 +36,7 @@ depth: 1 * Ensure there is a visual difference of 'active/current link' vs normal links in Windows high-contrast mode (Mohammad Areeb) * Avoid issues where trailing whitespace could be accidentally removed in translations for new page & snippet headers (Florian Vogt) * Make sure minimap error indicators follow the minimap scrolling (Thibaud Colas) + * Remove the ability to view or add comments to `InlinePanel` inner fields to avoid lost or incorrectly linked comments (Jacob Topp-Mugglestone) ### Documentation @@ -68,3 +69,11 @@ depth: 1 The `AbstractImage` and `AbstractRendition` models use a Wagtail-specific `WagtailImageField` which extends Django's `ImageField` to use [Willow](https://github.com/wagtail/Willow/) for image file handling. This will generate a new migration if you are using a [custom image model](custom_image_model) + +### Comments within `InlinePanel` not supported + +When the commenting system was introduced, support for `InlinePanel` fields was incorrectly added. This has lead to issues +where comments can be lost on save or in most cases will be added to the incorrect item within the `InlinePanel`. The ability +to add comments here has now been removed and as such any existing comments that were added will no longer show. + +See https://github.com/wagtail/wagtail/issues/9685 for tracking of adding this back officially in the future. diff --git a/wagtail/admin/templates/wagtailadmin/shared/field.html b/wagtail/admin/templates/wagtailadmin/shared/field.html index 591c18f7b2..91458621e3 100644 --- a/wagtail/admin/templates/wagtailadmin/shared/field.html +++ b/wagtail/admin/templates/wagtailadmin/shared/field.html @@ -66,7 +66,7 @@ {% endblock %} {% if show_add_comment_button %} -