Merged PR 390: [Sp17着手]ボタン押下時処理にpreventDefault()を行うものとおこなわないものが混在するのを整理する

## 概要
[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のスクショなど
- スクショ置き場

## 動作確認状況
- ローカルで確認

## 補足
- 相談、参考資料などがあれば
This commit is contained in:
maruyama.t 2023-09-08 05:27:52 +00:00
parent da1ee8a9c2
commit 82fb224d67
4 changed files with 4 additions and 41 deletions

View File

@ -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を実行することで、ポップアップのアンマウント時に初期化を行う

View File

@ -31,7 +31,7 @@ export const CardLicenseIssuePopup: React.FC<CardLicenseIssuePopupProps> = (
// ブラウザのウィンドウが閉じられようとしている場合に発火するイベントハンドラ
const handleBeforeUnload = (e: BeforeUnloadEvent) => {
// isLoadingがtrueの場合は確認ダイアログを表示す
// 後続の処理で、ブラウザのCSVダウンロードを行うため、ダイアログを表示させ
if (isLoading) {
e.preventDefault();
// ChromeではreturnValueが必要

View File

@ -291,8 +291,7 @@ export const LicenseOrderHistory: React.FC<LicenseOrderHistoryProps> = (
? styles.isActive
: ""
}`}
onClick={(event) => {
event.preventDefault();
onClick={() => {
issueLicense(x.poNumber);
}}
>
@ -312,8 +311,7 @@ export const LicenseOrderHistory: React.FC<LicenseOrderHistoryProps> = (
? styles.isActive
: ""
}`}
onClick={(event) => {
event.preventDefault();
onClick={() => {
onCancelIssue(
selectedRow.accountId,
x.poNumber

View File

@ -51,24 +51,7 @@ export const AddPartnerAccountPopup: React.FC<AddPartnerAccountPopup> = (
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;