Cannot use the latest release 0.11.1 in SPFX
We upgraded the botframework-webchat module to the latest version 0.11.1 in a SharePoint WebPart - SPFx project. The Project builds successfully, however getting following error when the page loads. TypeError: Cannot read property 'offsetWidth' of null at HistoryView.componentDidUpdate (History.tsx:48) at measureLifeCyclePerf (react-dom.js:4529) at react-dom.js:5183 at CallbackQueue.notifyAll (react-dom.js:948) at ReactReconcileTransaction.close (react-dom.js:11398) at ReactReconcileTransaction.closeAll (react-dom.js:14790) at ReactReconcileTransaction.perform (react-dom.js:14737) at ReactUpdatesFlushTransaction.perform (react-dom.js:14724) at ReactUpdatesFlushTransaction.perform (react-dom.js:12844) at Object.flushBatchedUpdates (react-dom.js:12927)
the Package.json has following related packages added. anything that is missing ?
"dependencies": { "@microsoft/sp-build-web": "^1.2.0", "@microsoft/sp-client-base": "^1.0.0", "@microsoft/sp-core-library": "^1.2.0", "@microsoft/sp-http": "^1.2.0", "@microsoft/sp-loader": "^1.2.0", "@microsoft/sp-lodash-subset": "^1.2.0", "@microsoft/sp-webpart-base": "^1.2.0", "@types/webpack-env": "^1.13.0", "microsoft-adaptivecards": "^0.6.1", "botframework-directlinejs": "^0.9.11", "botframework-webchat": "^0.11.1", "karma-mocha": "^1.3.0", "mocha": "^3.5.0", "tslint": "^5.7.0", "rxjs": "^5.4.3" }, "devDependencies": { "@microsoft/sp-module-interfaces": "^1.2.0", "@microsoft/sp-webpart-workbench": "^1.2.0", "@types/chai": "^4.0.4", "@types/lodash": "^4.14.74", "@types/mocha": "^2.2.42", "gulp": "^3.9.1", "react": "^15.6.1", "typescript": "^2.5.2" },
Hi @premaarya, this is a duplicate of issue #515 so I will close this and you can track the updates there.
The current behavior is that you cannot instantiate a Web Chat if it is not displayed. The workaround is to use visibility:hidden instead of display:none in your CSS, or other rendering techniques.
I did come across the #515, we are not using any custom css. Just packaging the botframework-webchat module to be used from sharepoint. Figured out we also need to add the react-dom package. Is there a list of packages that need to added along with version for using the latest version of botframework-webchat? if i use the the 15.4.2 version of react and react dom the error is fixed but the property window for the webpart not displayed. if i use the latest version of react and react-dom getting following error. TypeError: Cannot read property 'offsetWidth' of null at HistoryView.componentDidUpdate (History.tsx:48) at measureLifeCyclePerf (react-dom.js:4529) at react-dom.js:5183 at CallbackQueue.notifyAll (react-dom.js:948) at ReactReconcileTransaction.close (react-dom.js:11398) at ReactReconcileTransaction.closeAll (react-dom.js:14790) at ReactReconcileTransaction.perform (react-dom.js:14737) at ReactUpdatesFlushTransaction.perform (react-dom.js:14724) at ReactUpdatesFlushTransaction.perform (react-dom.js:12844) at Object.flushBatchedUpdates (react-dom.js:129 Anyone used it in SPFX ?
Hi @premaarya I'm not familiar with SPFX. Can you tell if it is hiding the Web Chat component temporarily? Perhaps you can try to set a breakpoint on that line to see if the chat is visible.
Hi @danmarshall SPFX is SharePoint Framework https://dev.office.com/sharepoint/docs/spfx/sharepoint-framework-overview
We are using this to create a Chat WebPart - using the BotFramework-WebChat npm. the Web Part just encapsulates the BotFramework-WebChat so that we can host it in the SharePoint Portal.
We debugged the issue and found following issue also please see the image of screen shot https://jeeo.blob.core.windows.net/spfxissues/s3.png and https://jeeo.blob.core.windows.net/spfxissues/s4.png
- File History.tsx row 48 const maxContentWidth = (this.carouselActivity.messageDiv.offsetParent as HTMLElement).offsetWidth - paddedWidth;
- After clicking "show web part parameters" this.carouselActivity.messageDiv.offsetParent equals NULL and throws an error.
- S4.png shows that messageDiv is visible as well as all it's ancestors.