Hi,
I'm struggling to find the cause of an issue that occurs sometimes after creating a new task. In summary:
When creating a new task with the + at the bottom of the column, the error below is sometimes reported in the console.
Unhandled rejection in promise: Cannot read properties of null (reading 'closest')
LogHelper.promiseRejectionUnhandled @ LogHelper.ts:45
LogHelper.ts:46 TypeError: Cannot read properties of null (reading 'closest')
at TaskBoard.resolveTaskItem (taskboard.umd.js31)
at SimpleTaskEdit.editTask (taskboard.umd.js20)
at TaskBoard.addTask (taskboard.umd.js234)
SimpleTaskEdit feature is enabled and that triggers the error because what is actually happening is your SimpleTaskEdit.js file the following code doesn't find the element:
editTask(taskRecord, element) {
const
me = this,
taskBoard = me.client;
// Get element from record if none supplied
if (!element) {
element = taskBoard.getTaskElement(taskRecord);
}
...
Specifically taskBoard.getTaskElement(taskRecord) returns null.
The reason for this I have found to be that the task html element still has the $PhantomId as part of the div id property and not the correct server assigned guid that was returned from the sync.
This only happens sometimes, so I'm guessing there is an async related cause why the task card doesn't get updated in time for the subsequent edit operation. But I'm lost after hours digging though your code and mine as what could be wrong on my side to cause this.
One last thing, the SimpleTaskEdit is not the cause as if that is disabled then no exception will occur but the task card will not refresh on the board correctly: specifically server side properties that are set on new tasks will not be shown immediately (only sometimes again though!).
Thanks for you support,
Martin