Workbench: Mobile View does not work with postMessage
- [x] Question
- [ ] Typo
- [x] Bug
- [ ] Additional article idea
Expected or Desired Behavior
Mobile View and Web View should bind "this" in the same way. The webpart should be rendered the same way in mobile and web view. "this" should refer to the same instance in both. I am using 1.6
Observed Behavior
I am trying to postMessages between webparts. send/listening works pretty well in web view but not in mobile view.
Steps to Reproduce
I am using your HelloWorldExample. Trying to change a state field via postMessage (Button "PostMessage") or calling the same event handler directly (Button "SetState").
It works perfectly in web view. If I switch to Mobile/Tablet and push the postMessage button, the text is not updated, but setState triggers a rendering on a different instance of the conrtol. Pushing the "SetState" button, which calls the eventListener directly is updating the text.
import * as React from 'react'; import { DefaultButton, autobind } from 'office-ui-fabric-react';
export interface IHelloWorld3State { msg: string; } export default class HelloWorld3 extends React.Component<{}, IHelloWorld3State> { constructor(props: {}) { super(props); this.state = { msg: "Learn more" }; } public render(): React.ReactElement<{}> { return (
@autobind private _clickURL(ignore: any): any { let md: any = {}; md.type = "HelloWorld"; md.msg = "done1"; let s: string = JSON.stringify(md); window.parent.postMessage(s, "*"); } @autobind private _clickURL2(ignore: any): any { let md: any = {}; md.type = "HelloWorld"; md.msg = "done2"; let s: string = JSON.stringify(md); this.eventListener({ data: s }); } }
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
@cfillies I cannot reproduce this issue because there are issues with the code you posted in the render method. Can you check if it still repros and if so can you post the code again?
This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within the next 7 days of this comment. Please see our wiki for more information: Issue List Labels: Needs Author Feedback & Issue List: No response from the original issue author
Closing issue due to no response from the original author. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: No response from the original issue author