瀏覽代碼

fix(ConfirmTooltip): if confirm isn't accepted (ie not direct click), it should hide

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan 4 年之前
父節點
當前提交
1e74195b60
共有 1 個文件被更改,包括 21 次插入7 次删除
  1. 21 7
      frontend/src/components/Confirm.vue

+ 21 - 7
frontend/src/components/Confirm.vue

@@ -5,14 +5,15 @@
 		theme="confirm"
 		ref="confirm"
 		trigger="click"
-		@hide="confirm(false)"
 	>
 		<template #trigger>
 			<div @click.shift.stop="confirm(true)" @click.exact="confirm()">
 				<slot />
 			</div>
 		</template>
-		<a @click.exact="confirm(true)"> Click to Confirm </a>
+		<a @click="confirm(null, $event)">
+			Click to Confirm
+		</a>
 	</tippy>
 </template>
 
@@ -30,15 +31,28 @@ export default {
 		};
 	},
 	methods: {
-		confirm(confirm) {
+		confirm(confirm, event) {
+			if (confirm === null) {
+				/* eslint-disable no-param-reassign */
+				if (
+					event &&
+					event.type === "click" &&
+					!event.altKey &&
+					!event.ctrlKey &&
+					!event.metaKey &&
+					!event.shiftKey
+				)
+					confirm = true;
+				else confirm = false;
+			}
+
 			if (confirm === false) {
 				this.clickedOnce = false;
+				this.$refs.confirm.tip.hide();
 			} else if (confirm === true || this.clickedOnce === true) {
-				this.$emit("confirm");
 				this.clickedOnce = false;
-			} else {
-				this.clickedOnce = true;
-			}
+				this.$emit("confirm");
+			} else this.clickedOnce = true;
 		}
 	}
 };