Commit f60d3e6
committed
Fix JavaScript TypeError: columns initialized as object instead of array
Problem:
- columns was initialized as an empty object {} in grid-component-type.phtml
- columns-selector-component-partial.phtml calls this.columns.forEach()
- Object.forEach() is not a function, causing TypeError and page hang
- Backend GridViewModel.getColumns() returns array of Column objects
Solution:
1. Changed columns: {} to columns: [] in grid-component-type.phtml:20
to match expected array type from backend
2. Added Array.isArray(this.columns) safety check before forEach()
in columns-selector-component-partial.phtml:15 to prevent future errors
Scan Results:
- Reviewed all .phtml files in the module for similar patterns
- All other object/array initializations are correct for their usage
- gridFilters: {} correctly used as object with bracket notation
- filters: [] correctly initialized as array in filters-component-partial
- No other array method calls on object-initialized properties found
This fix prevents the grid component from crashing when the columns
selector is initialized.1 parent 7f44b2e commit f60d3e6
2 files changed
Lines changed: 6 additions & 4 deletions
File tree
- view/adminhtml/templates/script
- component-partial
- component-type
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
0 commit comments