Commit 5b45df3
authored
fix(cdk/table): ensure CdkTable updates view with OnPush and trackBy (angular#31451)
When CdkTable is used with OnPush change detection and a `trackBy` function,
changes to the `dataSource` might not trigger a view update if the `trackBy`
function indicates that the rows themselves haven't changed (even if their
internal data has). This can leave the data-bound elements within the
table rows displaying outdated information.
This commit adds `markForCheck()` calls within the `_renderRows` method
of `CdkTable`. These calls ensure that when the table's data is updated
(even without full row re-creation due to `trackBy`), the component is
explicitly marked for change detection. This triggers a re-evaluation
of the bindings for all visible rows, ensuring the view remains
consistent with the underlying data.
Fixes angular#244831 parent c396821 commit 5b45df3
2 files changed
+45
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
1995 | 1996 | | |
1996 | 1997 | | |
1997 | 1998 | | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
1998 | 2028 | | |
1999 | 2029 | | |
2000 | 2030 | | |
| |||
3135 | 3165 | | |
3136 | 3166 | | |
3137 | 3167 | | |
3138 | | - | |
| 3168 | + | |
3139 | 3169 | | |
3140 | 3170 | | |
3141 | 3171 | | |
| |||
3163 | 3193 | | |
3164 | 3194 | | |
3165 | 3195 | | |
| 3196 | + | |
3166 | 3197 | | |
3167 | 3198 | | |
3168 | 3199 | | |
| |||
3176 | 3207 | | |
3177 | 3208 | | |
3178 | 3209 | | |
| 3210 | + | |
| 3211 | + | |
| 3212 | + | |
| 3213 | + | |
| 3214 | + | |
| 3215 | + | |
| 3216 | + | |
| 3217 | + | |
| 3218 | + | |
| 3219 | + | |
| 3220 | + | |
3179 | 3221 | | |
3180 | 3222 | | |
3181 | 3223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
| 685 | + | |
685 | 686 | | |
686 | 687 | | |
687 | 688 | | |
| |||
716 | 717 | | |
717 | 718 | | |
718 | 719 | | |
| 720 | + | |
719 | 721 | | |
720 | 722 | | |
721 | 723 | | |
| |||
0 commit comments