# Bug COMMS-1135 - Document editor stops saving after navigating directly from one document to another

Project: Stream Communicator
Status: new
URL: https://community.openproject.org/work_packages/COMMS-1135

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module |  |
| Target versions |  |
| Observed in versions |  |
| Sprint |  |
| Backlog bucket |  |
| Bug found in version (deprecated) |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

### Steps to reproduce

1. Enable real-time text collaboration and log in as a user who can edit documents in a project with two collaborative documents, A and B.
2. Open document A and type some text. It is saved.
3. Click "Documents" in the breadcrumb, then open document B and type some text. It is saved.
4. Open the browser's history list (long-press the back button) and jump straight back to document A, skipping the documents list.
5. Type some text in document A.

### What is the buggy behavior?

* The text typed in step 5 is never saved. The editor accepts input, but the document content on the server does not change.
* The same happens after jumping forward again to document B.
* Cause: the editor element of the new page registers with the collaboration manager while the previous page's provider is still live and receives that provider. The previous page's controller then destroys the provider and clears all registered listeners, so the new page's provider is never announced to the editor. The editor stays bound to a destroyed provider of the previous document.

### What is the expected behavior?

1. After any navigation to a document page, the editor is connected to that document and edits are saved.
2. The editor never receives a provider that belongs to another document.

### Notes

* Present on `dev` (reproduced at `d4ae5174f65`); independent of offline support (COMMS-649).
* Only direct document-to-document Turbo visits are affected. Navigating through the documents list, or opening a document link in a new tab, works.
* The comment on `destroyIfOwner` in `live-collaboration-helpers.ts` states that the old controller disconnects after the new one connects. The observed order is the opposite.
