From 82fb224d672913b54f3abe80e3a8643283d660f1 Mon Sep 17 00:00:00 2001 From: "maruyama.t" Date: Fri, 8 Sep 2023 05:27:52 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20390:=20[Sp17=E7=9D=80=E6=89=8B]?= =?UTF-8?q?=E3=83=9C=E3=82=BF=E3=83=B3=E6=8A=BC=E4=B8=8B=E6=99=82=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=81=ABpreventDefault()=E3=82=92=E8=A1=8C=E3=81=86?= =?UTF-8?q?=E3=82=82=E3=81=AE=E3=81=A8=E3=81=8A=E3=81=93=E3=81=AA=E3=82=8F?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=82=82=E3=81=AE=E3=81=8C=E6=B7=B7=E5=9C=A8?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=81=AE=E3=82=92=E6=95=B4=E7=90=86=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task2547: [Sp17着手]ボタン押下時処理にpreventDefault()を行うものとおこなわないものが混在するのを整理する](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2547) - 元PBI or タスクへのリンク(内容・目的などはそちらにあるはず) - 何をどう変更したか、追加したライブラリなど パートナー追加ポップアップで処理実行中にでブラウザを閉じようとしたときに確認ダイアログを表示していた箇所を削除(コピペ元からの削除漏れ) ライセンス注文履歴画面で、ボタン押下時に不要なpreventDefaultを行っていた箇所を削除 - このPull Requestでの対象/対象外 - 影響範囲(他の機能にも影響があるか) ## レビューポイント - 特にレビューしてほしい箇所 - 軽微なものや自明なものは記載不要 - 修正範囲が大きい場合などに記載 - 全体的にや仕様を満たしているか等は本当に必要な時のみ記載 ## UIの変更 - Before/Afterのスクショなど - スクショ置き場 ## 動作確認状況 - ローカルで確認 ## 補足 - 相談、参考資料などがあれば --- .../LicensePage/cardLicenseActivatePopup.tsx | 18 ------------------ .../LicensePage/cardLicenseIssuePopup.tsx | 2 +- .../pages/LicensePage/licenseOrderHistory.tsx | 6 ++---- .../PartnerPage/addPartnerAccountPopup.tsx | 19 +------------------ 4 files changed, 4 insertions(+), 41 deletions(-) diff --git a/dictation_client/src/pages/LicensePage/cardLicenseActivatePopup.tsx b/dictation_client/src/pages/LicensePage/cardLicenseActivatePopup.tsx index 1d2909e..6b7b79a 100644 --- a/dictation_client/src/pages/LicensePage/cardLicenseActivatePopup.tsx +++ b/dictation_client/src/pages/LicensePage/cardLicenseActivatePopup.tsx @@ -46,24 +46,6 @@ export const CardLicenseActivatePopup: React.FC< onClose(); }, [isLoading, onClose]); - // ブラウザのウィンドウが閉じられようとしている場合に発火するイベントハンドラ - const handleBeforeUnload = (e: BeforeUnloadEvent) => { - // isLoadingがtrueの場合は確認ダイアログを表示する - if (isLoading) { - e.preventDefault(); - // ChromeではreturnValueが必要 - e.returnValue = ""; - } - }; - // コンポーネントがマウントされた時にイベントハンドラを登録する - useEffect(() => { - window.addEventListener("beforeunload", handleBeforeUnload); - // コンポーネントがアンマウントされるときにイベントハンドラを解除する - return () => { - window.removeEventListener("beforeunload", handleBeforeUnload); - }; - }); - useEffect( () => () => { // useEffectのreturnとしてcleanupAppsを実行することで、ポップアップのアンマウント時に初期化を行う diff --git a/dictation_client/src/pages/LicensePage/cardLicenseIssuePopup.tsx b/dictation_client/src/pages/LicensePage/cardLicenseIssuePopup.tsx index 84b466d..9298a50 100644 --- a/dictation_client/src/pages/LicensePage/cardLicenseIssuePopup.tsx +++ b/dictation_client/src/pages/LicensePage/cardLicenseIssuePopup.tsx @@ -31,7 +31,7 @@ export const CardLicenseIssuePopup: React.FC = ( // ブラウザのウィンドウが閉じられようとしている場合に発火するイベントハンドラ const handleBeforeUnload = (e: BeforeUnloadEvent) => { - // isLoadingがtrueの場合は確認ダイアログを表示する + // 後続の処理で、ブラウザのCSVダウンロードを行うため、ダイアログを表示させる if (isLoading) { e.preventDefault(); // ChromeではreturnValueが必要 diff --git a/dictation_client/src/pages/LicensePage/licenseOrderHistory.tsx b/dictation_client/src/pages/LicensePage/licenseOrderHistory.tsx index cc6d2ca..aee1606 100644 --- a/dictation_client/src/pages/LicensePage/licenseOrderHistory.tsx +++ b/dictation_client/src/pages/LicensePage/licenseOrderHistory.tsx @@ -291,8 +291,7 @@ export const LicenseOrderHistory: React.FC = ( ? styles.isActive : "" }`} - onClick={(event) => { - event.preventDefault(); + onClick={() => { issueLicense(x.poNumber); }} > @@ -312,8 +311,7 @@ export const LicenseOrderHistory: React.FC = ( ? styles.isActive : "" }`} - onClick={(event) => { - event.preventDefault(); + onClick={() => { onCancelIssue( selectedRow.accountId, x.poNumber diff --git a/dictation_client/src/pages/PartnerPage/addPartnerAccountPopup.tsx b/dictation_client/src/pages/PartnerPage/addPartnerAccountPopup.tsx index 565bfe7..43453b8 100644 --- a/dictation_client/src/pages/PartnerPage/addPartnerAccountPopup.tsx +++ b/dictation_client/src/pages/PartnerPage/addPartnerAccountPopup.tsx @@ -51,24 +51,7 @@ export const AddPartnerAccountPopup: React.FC = ( const email = useSelector(selectEmail); const isLoading = useSelector(selectIsLoading); - // ブラウザのウィンドウが閉じられようとしている場合に発火するイベントハンドラ - const handleBeforeUnload = (e: BeforeUnloadEvent) => { - // isLoadingがtrueの場合は確認ダイアログを表示する - if (isLoading) { - e.preventDefault(); - // ChromeではreturnValueが必要 - e.returnValue = ""; - } - }; - // コンポーネントがマウントされた時にイベントハンドラを登録する - useEffect(() => { - window.addEventListener("beforeunload", handleBeforeUnload); - // コンポーネントがアンマウントされるときにイベントハンドラを解除する - return () => { - window.removeEventListener("beforeunload", handleBeforeUnload); - }; - }); - + // ポップアップを閉じる処理 const closePopup = useCallback(() => { if (isLoading) { return;