Commit 2b25f24
committed
fix(uiGrid): Fix race condition in data watcher
The data watch function is creating a condition where promises can get
resolved out of order. If you are fetching both cell templates and data
over the network, it will operate thusly:
1. Data watch fires with empty data array, it sees there's no columns set
up and builds them from the columnDefs. This uses a promise from the
preCompileCellTemplates function.
2. The new data comes in, the data watcher sees there's columns set up now
so nothing has to be done and it sets the rows to your new data. Yay!
3. The promise from preCompileCellTemplates completes, and the data is
updated AGAIN, but this time with the original empty data set, blowing
away the data you fetched.
This fix changes the operation so we only call buildColumnDefsFromData()
when we actually HAVE data to use, and buildColumns() gets called if we
either have data OR have columnDefs.
Fixes #20531 parent 75bd9f0 commit 2b25f24
1 file changed
+23
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
73 | 85 | | |
74 | 86 | | |
75 | | - | |
76 | | - | |
| 87 | + | |
| 88 | + | |
77 | 89 | | |
| 90 | + | |
78 | 91 | | |
79 | | - | |
| 92 | + | |
80 | 93 | | |
81 | 94 | | |
82 | 95 | | |
| |||
0 commit comments