Bug: Collaboration Plugin does not update the provider when providerFactory is updated.
- Dominant language
- TypeScript
- Stars
- 23.9k
- Forks
- 2.2k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 55
Description
Lexical version: 0.23.1
## Steps To Reproduce
1. Update providerFactory during collaboration.
2. Provider is not updated.
## The current behavior
Provider is not updated by updationg providerFactory.
This behavior caused by [this line](https://github.com/facebook/lexical/blob/df72ec4fed6747b3215dbfe9a1e0478fc9383673/packages/lexical-react/src/LexicalCollaborationPlugin.tsx#L86).
## The expected behavior
Provider can be updated when providerFactory is updated.
## The problem I hit
I want to update providerFactory every time when id token is updated to prevent connection lost.
So I write the code like below.
``` typescript
const MyCollaborationPlugin = () => {
const idToken = useIdToken();
// This function updates triggered by update of token.
const providerFactoryFunction = useCallback(
(id: string, yjsDocMap: Map) => {
const doc = getDocFromMap(id, yjsDocMap);
return new WebsocketProvider('wss://test.com', id, doc, {
connect: false,
params: {
id_token: idToken,
item_id: id,
},
});
},
[idToken],
);
return ;
};
```
However, [lexical implementation](https://github.com/facebook/lexical/blob/df72ec4fed6747b3215dbfe9a1e0478fc9383673/packages/lexical-react/src/LexicalCollaborationPlugin.tsx#L86) looks like preventing update provider. So I want to remove the line if it is possible.
## Impact of fix
In the current implementation, if the ID token is updated after the WebSocket connection has been established and the connection is subsequently lost, the providerFactory isn’t updated.
As a result, the query parameter for the ID token remains outdated, preventing the connection from being re-established. With solving this issue, updating the ID token will allow the connection to be restored.
Contributor guide
Assessment
This issue has not been assessed yet.