You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 6, 2023. It is now read-only.
Fix DraftTreeAdapter to respect the tree invariants
Summary:
`DraftTreeAdapter` is called to convert list-data style Content Blocks into a valid Tree Data structure.
* The Tree Data structure has an invariant that only leaf nodes (i.e. nodes with no children) can have text in them. To respect this invariant, we need to create a new parent block at each level of a nested list. By implementing this, we fix a bug with the rendering of nested lists.
* Also adds the tree invariant check in DEV mode in `convertFromRawToDraftState` (which calls the tree adapter) to flag if this structure breaks again due to any updates.
* Re-record snapshot for `DraftTreeAdapter-test.js` and `convertFromRawToDraftState-test.js`
Reviewed By: mitermayer
Differential Revision: D9524985
fbshipit-source-id: f5828dfb5f12cb4e34c8511456a79457c1a09808
Copy file name to clipboardExpand all lines: src/component/utils/exploration/__tests__/__snapshots__/DraftTreeAdapter-test.js.snap
+44-8
Original file line number
Diff line number
Diff line change
@@ -26,8 +26,22 @@ Object {
26
26
exports[`must be able to convert from raw state to raw tree state with nested trees based on lists depth 1`] =`
27
27
Object {
28
28
"blocks": Array [
29
+
Object {
30
+
"children": Array [],
31
+
"depth": 0,
32
+
"key": "A",
33
+
"text": "Alpha",
34
+
"type": "ordered-list-item",
35
+
},
29
36
Object {
30
37
"children": Array [
38
+
Object {
39
+
"children": Array [],
40
+
"depth": 1,
41
+
"key": "B",
42
+
"text": "Beta",
43
+
"type": "ordered-list-item",
44
+
},
31
45
Object {
32
46
"children": Array [
33
47
Object {
@@ -39,8 +53,10 @@ Object {
39
53
},
40
54
],
41
55
"depth": 1,
42
-
"key": "B",
43
-
"text": "Beta",
56
+
"entityRanges": Array [],
57
+
"inlineStyleRanges": Array [],
58
+
"key": "key1",
59
+
"text": "",
44
60
"type": "ordered-list-item",
45
61
},
46
62
Object {
@@ -52,8 +68,10 @@ Object {
52
68
},
53
69
],
54
70
"depth": 0,
55
-
"key": "A",
56
-
"text": "Alpha",
71
+
"entityRanges": Array [],
72
+
"inlineStyleRanges": Array [],
73
+
"key": "key0",
74
+
"text": "",
57
75
"type": "ordered-list-item",
58
76
},
59
77
],
@@ -64,6 +82,13 @@ Object {
64
82
exports[`must be able to convert from raw state to raw tree state with nested trees based on lists depth and attach nested blocks to closest depth parent 1`] =`
0 commit comments