Problem/Motivation

The 'Collapse footnotes with identical content' option works, as in that identical references don't appear multiple times in the grouped footer. There's one problem though: when an identical footnote is found in a subsequent text field, its reference isn't added to the footer again but its citation is renumbered, causing it to link to a non-existing reference.

Steps to reproduce

Add an identical footnote to a field different than the original one, with collapsing and grouping enabled.

Proposed resolution

In \Drupal\footnotes\Plugin\Filter\FootnotesFilter::getMatchingFootnoteKey(), don't just check the footnotes of the current filter. Check footnotes from the group as well.

Issue fork footnotes-3519927

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dieterholvoet created an issue. See original summary.

dieterholvoet’s picture

Assigned: dieterholvoet » Unassigned
Status: Active » Needs review

scott_euser made their first commit to this issue’s fork.

scott_euser’s picture

Assigned: Unassigned » scott_euser
Status: Needs review » Needs work

Thanks @dieterholvoet for the start on this!

We have been working on a giant publication with hundreds of footnotes and we have also realised that when across multiple fields, not only is the grouping not shared for identical numbers, the matching of same text appearing in different fields does not group those still.

Working on some refactoring to share some of the FootnotesFilter code with FootnotesGroup - moved to a separate branch for now.

Seems to be working for now, but will be adding test coverage to this as its a problem that has come back too often.

scott_euser’s picture

Assigned: scott_euser » Unassigned
Status: Needs work » Needs review

Okay got some more automated test coverage in as well to ensure with & without grouping works okay. Will leave this here for a little bit as needs review in case anyone has any concerns

scott_euser changed the visibility of the branch 3519927-citations-are-not to hidden.

sbrockwell’s picture

This fix seems to be working for me. I've tested using the same footnote across multiple paragraphs of different types, alongside the same footnote within one paragraph and the footnote is merged as expected across all permutations in my test case.

  • scott_euser committed 35c864a9 on 4.0.x
    [#3519927] fix: Citations are not reused when collapsing footnotes...
scott_euser’s picture

Status: Needs review » Fixed

Thanks for testing it out and confirming. Will be part of the next release

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.