collectives icon indicating copy to clipboard operation
collectives copied to clipboard

Heading anchors point to `#undefined` in view mode

Open mejo- opened this issue 1 year ago • 4 comments

Describe the bug Heading anchors point to #undefined in view mode.

To Reproduce Steps to reproduce the behavior:

  1. Create a document with headings
  2. Switch to view mode
  3. Hover over the # symbol left to a heading and see the URL.

Server details:

  • Collectives app version: latest
  • Nextcloud version: 27.1.5

mejo- avatar Feb 16 '24 12:02 mejo-

not reproducible for me in current main branch after running npm ci && npm run watch

Koc avatar Mar 12 '24 11:03 Koc

I have the same problem. Only in view mode anchor points to #undefined. In edit mode the anchor points to the correct position. When view-mode is set as default and you open a link with the correct anchor it wont show the correct position.

Collectives app version: 2.10.0 Nextcloud: 28.0.3

AngryNui avatar Mar 14 '24 13:03 AngryNui

The problem seems to be related to updating the page content of MarkdownContentEditor.vue with the content from Editor.vue. Here and here we do setContent() on the MarkdownContentEditor.vue. Before that, the anchor links still work, afterwards, they point to undefined.

mejo- avatar Mar 25 '24 13:03 mejo-

Findings

I looked into this issue, couldn't quite figure it out but still possibly made some findings. The Links for headings are created in extractor.js and called by either onUpdate or onCreate in nodes/Heading/index.js

the links rendering as undefined most likely has something to do with the lifecycle hooks not beeing called in the way they are ment to be. Somehow the setupReader and setupEditor functions in collectives that start those editors make it so the reader and editor influence one another.

Inspecting the stack trace with breakpoints it was visible that addNode in nodes/Heading/index.js was called before the onCreated Hook which could possibly cause issues. Another possibility would be that the influence of different orders of setContent-calls in collectives affects the link-values, which would bring up the question why setContent calls don't all trigger the same update cycle.

I don't know if any of that will be helpful but I did my best.

grnd-alt avatar Mar 28 '24 13:03 grnd-alt

This finally got fixed in Text with nextcloud/text#5893.

mejo- avatar Jul 25 '24 14:07 mejo-