[COMPASS-6188] Grid view: can't cancel editing document when a field previously missing is set Created: 11/Oct/22  Updated: 03/Oct/23  Resolved: 05/Jun/23

Status: Closed
Project: Compass
Component/s: CRUD, Table View
Affects Version/s: None
Fix Version/s: No version

Type: Bug Priority: Major - P3
Reporter: Maurizio Casimirri Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OS:
node.js / npm versions:
Additional info:


Documentation Changes: Not Needed

 Description   

Steps to reproduce:
1 - open a collection with documents where a property is present only on some (for example: Corporate-Registrations.agent_city in Compass).
2 - switch to the table view
3 - edit a row
4 - click on a missing property
(a cell with "No Field")
5 - click cancel

Cancel would fail, and an error is thrown:

Cannot read properties of undefined (reading 'elements')
 
Call Stack
 Element.revert
  MongoDBCompass/../hadron-document/src/element.ts:716:19
 CellEditor.isCancelAfterEnd
  MongoDBCompass/../compass-crud/src/components/table-view/cell-editor.jsx:288:22
 LegacyReactComponent.BaseReactComponent.callMethod
  MongoDBCompass/../../node_modules/ag-grid-react/lib/baseReactComponent.js:25:27
 LegacyReactComponent.eval [as isCancelAfterEnd]
  MongoDBCompass/../../node_modules/ag-grid-community/dist/lib/components/framework/frameworkComponentWrapper.js:30:32
 CellComp.stopEditing
  MongoDBCompass/../../node_modules/ag-grid-community/dist/lib/rendering/cellComp.js:1503:89
 eval
  MongoDBCompass/../../node_modules/ag-grid-community/dist/lib/rendering/rowComp.js:826:26
 eval
  MongoDBCompass/../../node_modules/ag-grid-community/dist/lib/rendering/rowComp.js:869:13
 Function.Utils.iterateObject
  MongoDBCompass/../../node_modules/ag-grid-community/dist/lib/utils.js:206:17
 RowComp.forEachCellComp
  MongoDBCompass/../../node_modules/ag-grid-community/dist/lib/rendering/rowComp.js:865:19
 RowComp.stopEditing
  MongoDBCompass/../../node_modules/ag-grid-community/dist/lib/rendering/rowComp.js:825:14

The error points to this line: https://github.com/mongodb-js/compass/blob/56203bbd83efb59fd611bbc81d2e0cb330aaeebd/packages/hadron-document/src/element.ts#L685



 Comments   
Comment by Rhys Howell [ 05/Jun/23 ]

Fixed in COMPASS-6505

Generated at Wed Feb 07 22:42:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.