aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-11-04 17:17:49 +0800
committercrupest <crupest@outlook.com>2020-11-04 17:17:49 +0800
commitf54b914b4573530e89e9ad97dadb37024eedc91e (patch)
tree57b14ebe778ca4313b8ec7dc421346086ea9c671
parent8f4b972fc06bfbe3f2b1330472c3b704f0759eec (diff)
downloadtimeline-f54b914b4573530e89e9ad97dadb37024eedc91e.tar.gz
timeline-f54b914b4573530e89e9ad97dadb37024eedc91e.tar.bz2
timeline-f54b914b4573530e89e9ad97dadb37024eedc91e.zip
feat: Click on alert makes alert not auto dismiss.
-rw-r--r--FrontEnd/src/app/views/common/alert/AlertHost.tsx9
1 files changed, 9 insertions, 0 deletions
diff --git a/FrontEnd/src/app/views/common/alert/AlertHost.tsx b/FrontEnd/src/app/views/common/alert/AlertHost.tsx
index c74f18e2..f50e41ad 100644
--- a/FrontEnd/src/app/views/common/alert/AlertHost.tsx
+++ b/FrontEnd/src/app/views/common/alert/AlertHost.tsx
@@ -22,6 +22,8 @@ export const AutoCloseAlert: React.FC<AutoCloseAlertProps> = (props) => {
const { t } = useTranslation();
+ const timerTag = React.useRef<number | null>(null);
+
React.useEffect(() => {
const tag =
dismissTime === "never"
@@ -29,6 +31,7 @@ export const AutoCloseAlert: React.FC<AutoCloseAlertProps> = (props) => {
: typeof dismissTime === "number"
? window.setTimeout(props.close, dismissTime)
: window.setTimeout(props.close, 5000);
+ timerTag.current = tag;
return () => {
if (tag != null) {
window.clearTimeout(tag);
@@ -40,6 +43,12 @@ export const AutoCloseAlert: React.FC<AutoCloseAlertProps> = (props) => {
<Alert
className="m-3"
variant={alert.type ?? "primary"}
+ onClick={() => {
+ const { current: tag } = timerTag;
+ if (tag != null) {
+ window.clearTimeout(tag);
+ }
+ }}
onClose={props.close}
dismissible
>