From 9c0e0db80aca89ae884da9d899fec93095a6953f Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Sat, 2 Oct 2021 01:18:41 +0300 Subject: [PATCH 1/2] Fix bug 52895: warning when leaving a page --- .../Section/Body/updateUserForm.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/products/ASC.People/Client/src/pages/ProfileAction/Section/Body/updateUserForm.js b/products/ASC.People/Client/src/pages/ProfileAction/Section/Body/updateUserForm.js index ceefeb637f..0eabd68d4b 100644 --- a/products/ASC.People/Client/src/pages/ProfileAction/Section/Body/updateUserForm.js +++ b/products/ASC.People/Client/src/pages/ProfileAction/Section/Body/updateUserForm.js @@ -101,13 +101,38 @@ class UpdateUserForm extends React.Component { this.onSelectGroups = this.onSelectGroups.bind(this); this.onRemoveGroup = this.onRemoveGroup.bind(this); + this.handleWindowBeforeUnload = this.handleWindowBeforeUnload.bind(this); + this.mainFieldsContainerRef = React.createRef(); } componentDidMount() { this.props.setIsEditTargetUser(true); + + this.unblock = this.props.history.block((targetLocation) => { + if (this.props.isEdit) { + this.props.setIsVisibleDataLossDialog(true); + return false; + } + + return true; + }); + + window.addEventListener("beforeunload", this.handleWindowBeforeUnload); } + componentWillUnmount() { + this.unblock(); + window.removeEventListener("beforeunload", this.handleWindowBeforeUnload); + } + + handleWindowBeforeUnload = (e) => { + if (this.props.isEdit) { + e.preventDefault(); + e.returnValue = ""; + } + }; + componentDidUpdate(prevProps, prevState) { if (this.props.match.params.userId !== prevProps.match.params.userId) { this.setState(this.mapPropsToState(this.props)); @@ -318,6 +343,8 @@ class UpdateUserForm extends React.Component { personal, } = this.props; + this.unblock(); + if (personal) { history.push(combineUrl(AppServerConfig.proxyURL, "/my")); } else if (isEditTargetUser || document.referrer) { From ed20953d9c4735fca30d484a0cb822094b378a20 Mon Sep 17 00:00:00 2001 From: AlexeySafronov Date: Tue, 5 Oct 2021 14:57:42 +0300 Subject: [PATCH 2/2] Web: Hide warning overlay --- web/ASC.Web.Client/webpack.config.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web/ASC.Web.Client/webpack.config.js b/web/ASC.Web.Client/webpack.config.js index b3707a7492..1c506f98c7 100644 --- a/web/ASC.Web.Client/webpack.config.js +++ b/web/ASC.Web.Client/webpack.config.js @@ -21,6 +21,10 @@ const config = { entry: "./src/index", mode: "development", + stats: { + errorDetails: true, + }, + devServer: { devMiddleware: { publicPath: homepage, @@ -38,7 +42,9 @@ const config = { // errors: true, // warnings: true, // } - overlay: true, + overlay: { + warnings: false, + }, progress: true, }, port: 5001,