|
<DialogComponent id="defaultdialog" showCloseIcon={true} animationSettings={this.animationSettings}
visible={this.state.hideDialog} width={'500px'} ref={dialog=> (this.dialogInstance = dialog)}
target={'#targetElement'}
header="About SYNCFUSION Succinctly Series"
buttons={this.buttons}
open={this.dialogOpen.bind(this)}
close={this.dialogClose.bind(this)}
>
<form onSubmit={this.submitHandler}>
. . .
<ButtonComponent content="Cancel" className="e-secondary cancel-btn" type="button"
onClick={this.cancelBtnHandler.bind(this)} />
. . .
</form>
</DialogComponent> |
|
<DialogComponent id="defaultdialog" showCloseIcon={true} animationSettings={this.animationSettings}
visible={this.state.hideDialog} width={'500px'} ref={dialog=> (this.dialogInstance = dialog)}
target={'#targetElement'}
header="About SYNCFUSION Succinctly Series"
buttons={this.buttons}
open={this.dialogOpen.bind(this)}
close={this.dialogClose.bind(this)}
>
<form onSubmit={this.submitHandler}>
<div>
. . .
<ButtonComponent content="Save" className="e-secondary cancel-btn" type="button"
onClick={this.submitHandler.bind(this)} />
</form>
</DialogComponent> |
|
export default function App() {
this.content = () => {
return (
<div className="dialogContent">
<button onClick={clickHandler.bind(this)}>click</button>
</div>
);
};
const clickHandler = () => {
console.log("hello");
};
return (
<div>
<DialogComponent
width="250px"
visible={true}
content={this.content.bind(this)}
></DialogComponent>
</div>
);
} |
Hi Darek,
I bumped into issue 2 myself - and I saw that SF's answer from Revanth was to use the content property instead of having components as children of DialogComponent, but I found that doing that can have its own issues (due to the order stuff gets rendered).
There's actually a simpler answer which is to just set a target on the DialogComponent that's either targetting your app root or some other element below it (rather than one outside the app, which the default of the body element is).
I forked the earlier code snippet that wasn't working and set a target property of the app root and it now works without needing to change to using the content property:
https://codesandbox.io/s/determined-dust-jgzymp?file=/src/App.js
I think the original issue is a consequence of how React does click event handling (it binds a noop function to the element and then catches the click event higher up the dom tree).
I've raised a bug report with SF about this behaviour with the DialogComponent as I think at the very least the documentation for the DialogComponent should warn that not setting the target can have consequences for click handlers!
Hi Matt,
We truly appreciate your feedback and apologize for any inconvenience you may have faced with our documentation.
Thank you for taking the time to create feedback about the issue you encountered. Your suggestion regarding the use of the target property on the DialogComponent is indeed valuable. It's great to see that you found a simpler solution to the problem and shared it with us. We've taken note of your feedback and will incorporate it into our documentation to ensure that other users are aware of this potential issue with click event handling. We will prioritize this update and make sure our documentation reflects this information promptly.
Thank you once again for your time and valuable insights.
Regards,
Kokila Poovendran