Open dev console, paste and execute window.setData({...window.data, header: '123123'}).
Go to editor revision history.
Expected
Only header root is marked as changed.
Actual
All roots are marked as changed:
A bit of context
This happens because setData returned from useMultiRootEditor hook, expects all roots to be passed (since it diffs root list enabling to add/remove them) and existing roots are just updated with passed data, even if it's the same. Such update results in each root model data to be wiped out and re-added which is interpreted by revision history as complete data replace (since it works on model operations and does not diff data changes).
Reproduction steps
It can be done in multiple ways, the fastest for me was by using collaboration samples.
data
andsetData
returned byuseMultiRootEditor
. This can be done by modifying this line as:yarn && yarn dev
.window.setData({...window.data, header: '123123'})
.Expected
Only
header
root is marked as changed.Actual
All roots are marked as changed:
A bit of context
This happens because
setData
returned fromuseMultiRootEditor
hook, expects all roots to be passed (since it diffs root list enabling to add/remove them) and existing roots are just updated with passed data, even if it's the same. Such update results in each root model data to be wiped out and re-added which is interpreted by revision history as complete data replace (since it works on model operations and does not diff data changes).