Collapse footnotes with identical content should work for all footnotes on the page, not just those in the current field being rendered

Created on 19 May 2025, about 1 month ago

Problem/Motivation

Collapse footnotes with identical content only collapses some footnotes. Specifically, FootnotesFilter::getMatchingFootnoteKey() only checks $this->storedFootnotes, but it should also check $this->footnotesGroup->matches (though matches is a protected variable).

Steps to reproduce

  1. Create a content type with two fields that accept footnotes and configure A. Collapse footnotes with identical content and B. Disable output of the footnotes footer so that you render Footnotes with the Footnotes block
  2. Create content with the footnotes in both fields, and with at least one footnote in each field with the same footnote content
  3. See that the footnotes in different fields, but with the same content are not collapsed.

Proposed resolution

Update FootnotesFilter::getMatchingFootnoteKey() to also check $this->footnotesGroup->matches for identical footnotes.

For example:

protected function getMatchingFootnoteKey(string $text): string {
    // $matches is a protected var so we'll need to add a getter
    foreach ($this->footnotesGroup->matches as $key => $footnotes) {
      foreach ($footnotes as $footnote) {
        if ($text == $footnote['text']) {
          return $key;
        }
      }
    }
    foreach ($this->storedFootnotes as $key => $footnotes) {
      foreach ($footnotes as $footnote) {
        if ($text == $footnote['text']) {
          return $key;
        }
      }
    }
    return '';
  }

Remaining tasks

  1. Make the update
  2. Test the update

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Active

Version

4.0

Component

Footnotes

Created by

πŸ‡ΊπŸ‡ΈUnited States sonfd Portland, ME

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024