[bug] [edgeless] Changing text in shapes does not render in other tab by sync
Currently, rendering occurs when the model is changed, specifically when
- adding
- deleting
- or modifying geometry / props
However, there is no reaction to text changes, so when modifying text inside the shape, the render in the second tab will happen only on the next model element change.
@doodlewind any news?
@RubaXa thanks for the feedback! It's reproduced and I believe we'll land refactoring on edgeless data flow that fixes this together in this iteration. /cc @doouding
To be noted:
It seems that everything should work out from the box initially, because @yfield decorator already contains the code block to run refresh on Y props changes, because it contains the call to startObserve(prototype, prop as string, this); method.
But, this flow is broken inside observer itself, because if no observer function provided, observer just quits here @blocksuite/blocks/src/surface-block/element-model/decorators/observer.ts
...
if (!observeFn) {
return;
}
...
and by default it is not provided anywhere at @yfield declaration
That's right, it works almost out of the box. The problem is in the syncElementFromY (onElementChange in previous ver)
There is a subscription to change Y.Map fields, but not nested fields. Y.Text is already a nested field, so its events are ignored, which does not lead to an update trigger between clients.
To solve this problem, you need to change .observe to .observeDeep and support changes to all nested fields in the element model.