Commit fc7c60c
perf(data-grid): optimize rerenders (#1104)
* perf: optimize data-grid following Vercel React best practices
- Add optimizePackageImports for lucide-react tree-shaking
- Use functional setState in MultiSelectCell for stable callbacks
- Add searchMatchSet for O(1) search lookups instead of O(n) .some()
- Extract serializeCellsToTsv helper to combine iterations and DRY copy/cut
- Add content-visibility CSS to virtualized rows
Co-authored-by: Cursor <cursoragent@cursor.com>
* perf: convert constant lookup arrays to Sets for O(1) checks
- NON_NAVIGABLE_COLUMN_IDS in use-data-grid.ts
- REMOVE_FILTER_SHORTCUTS, OPERATORS_WITHOUT_VALUE in data-grid-filter-menu.tsx
- REMOVE_SORT_SHORTCUTS in data-grid-sort-menu.tsx
- Add seenColumnIds Set for O(1) deduplication in serializeCellsToTsv
Co-authored-by: Cursor <cursoragent@cursor.com>
* perf: optimize column lookups and extract shared helper
- Add getEmptyValueForVariant helper to DRY empty value logic
- Build columnById Map for O(1) lookups in paste/delete handlers
- Build cellById Map for O(1) lookups in search function
- Convert tableColumns.find() and getVisibleCells().find() to Map.get()
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor: move getEmptyCellValue to lib and remove redundant comments
- Rename getEmptyValueForVariant to getEmptyCellValue
- Move helper to src/lib/data-grid.ts for reusability
- Remove comments that just describe what code does
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore: rebuild registry
* perf: optimize cell variants with Map/Set lookups and rebuild registry
- Add optionByValue Map for O(1) label lookups in SelectCell and MultiSelectCell
- Add selectedValuesSet for O(1) selection checks in MultiSelectCell
- Fix missing @ prefix in tanstack packages in optimizePackageImports
- Rebuild registry
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore: rebuild registry again
* fix: address Copilot review feedback
- Move event.preventDefault() outside setState callback for synchronous execution
- Cache cellMap per row in serializeCellsToTsv to avoid redundant Map creation
- Fix TypeScript type for rowCellMaps
Co-authored-by: Cursor <cursoragent@cursor.com>
* chore: rebuild registry again again
* chore: update demo
* chore: update callcabks
---------
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 34b05c6 commit fc7c60c
File tree
11 files changed
+153
-186
lines changed- public/r
- src
- app/data-grid/components
- components/data-grid
- hooks
- lib
11 files changed
+153
-186
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
14 | 23 | | |
15 | 24 | | |
16 | 25 | | |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 102 | + | |
106 | 103 | | |
107 | 104 | | |
108 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
874 | 874 | | |
875 | 875 | | |
876 | 876 | | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
877 | 881 | | |
878 | 882 | | |
879 | 883 | | |
| |||
918 | 922 | | |
919 | 923 | | |
920 | 924 | | |
921 | | - | |
922 | | - | |
| 925 | + | |
923 | 926 | | |
924 | 927 | | |
925 | 928 | | |
| |||
1015 | 1018 | | |
1016 | 1019 | | |
1017 | 1020 | | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
1018 | 1025 | | |
1019 | 1026 | | |
1020 | 1027 | | |
| |||
1031 | 1038 | | |
1032 | 1039 | | |
1033 | 1040 | | |
1034 | | - | |
1035 | | - | |
1036 | | - | |
1037 | | - | |
1038 | | - | |
1039 | | - | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
1040 | 1052 | | |
1041 | | - | |
1042 | 1053 | | |
1043 | | - | |
| 1054 | + | |
1044 | 1055 | | |
1045 | 1056 | | |
1046 | 1057 | | |
1047 | 1058 | | |
1048 | 1059 | | |
1049 | 1060 | | |
1050 | 1061 | | |
1051 | | - | |
1052 | | - | |
1053 | | - | |
1054 | | - | |
1055 | | - | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
1056 | 1071 | | |
1057 | | - | |
| 1072 | + | |
1058 | 1073 | | |
1059 | 1074 | | |
1060 | 1075 | | |
| |||
1103 | 1118 | | |
1104 | 1119 | | |
1105 | 1120 | | |
1106 | | - | |
1107 | | - | |
1108 | | - | |
1109 | | - | |
1110 | | - | |
1111 | | - | |
| 1121 | + | |
1112 | 1122 | | |
1113 | | - | |
1114 | | - | |
1115 | | - | |
1116 | | - | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
1117 | 1135 | | |
1118 | | - | |
1119 | | - | |
1120 | 1136 | | |
1121 | 1137 | | |
1122 | 1138 | | |
1123 | 1139 | | |
1124 | | - | |
| 1140 | + | |
1125 | 1141 | | |
1126 | 1142 | | |
1127 | 1143 | | |
1128 | | - | |
| 1144 | + | |
1129 | 1145 | | |
1130 | 1146 | | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
1131 | 1152 | | |
1132 | 1153 | | |
1133 | 1154 | | |
| |||
1169 | 1190 | | |
1170 | 1191 | | |
1171 | 1192 | | |
1172 | | - | |
1173 | | - | |
| 1193 | + | |
1174 | 1194 | | |
1175 | 1195 | | |
1176 | 1196 | | |
| |||
1205 | 1225 | | |
1206 | 1226 | | |
1207 | 1227 | | |
1208 | | - | |
| 1228 | + | |
1209 | 1229 | | |
1210 | 1230 | | |
1211 | 1231 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
59 | 64 | | |
60 | 65 | | |
61 | 66 | | |
| |||
177 | 182 | | |
178 | 183 | | |
179 | 184 | | |
180 | | - | |
| 185 | + | |
181 | 186 | | |
182 | 187 | | |
183 | 188 | | |
| |||
340 | 345 | | |
341 | 346 | | |
342 | 347 | | |
343 | | - | |
| 348 | + | |
344 | 349 | | |
345 | 350 | | |
346 | 351 | | |
| |||
357 | 362 | | |
358 | 363 | | |
359 | 364 | | |
360 | | - | |
| 365 | + | |
361 | 366 | | |
362 | 367 | | |
363 | 368 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
| 214 | + | |
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
| 159 | + | |
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| |||
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
316 | | - | |
| 316 | + | |
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
| |||
0 commit comments