From 0e288ea92d5529265b118589f92c5c39d81b5155 Mon Sep 17 00:00:00 2001 From: LouisLam Date: Tue, 7 Sep 2021 17:06:33 +0800 Subject: [PATCH] disable chrome save password dialog for autocompelete = off only --- src/components/HiddenInput.vue | 33 ++++++++++++++++++++++++--- src/components/NotificationDialog.vue | 2 +- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/components/HiddenInput.vue b/src/components/HiddenInput.vue index 0dfb4b5e7..7ec9f2e49 100644 --- a/src/components/HiddenInput.vue +++ b/src/components/HiddenInput.vue @@ -13,8 +13,8 @@ :maxlength="maxlength" :autocomplete="autocomplete" :required="required" - readonly - onfocus="this.removeAttribute('readonly');" + :readonly="isReadOnly" + @focus="removeReadOnly" > @@ -47,10 +47,15 @@ export default { required: { type: Boolean }, + readonly: { + type: Boolean, + default: false, + }, }, data() { return { - visibility: "password" + visibility: "password", + readOnlyValue: false, } }, computed: { @@ -61,6 +66,21 @@ export default { set(value) { this.$emit("update:modelValue", value) } + }, + isReadOnly() { + // Actually readonly from prop + if (this.readonly) { + return true; + } + + // Hack - Disable Chrome save password + return this.readOnlyValue; + } + }, + created() { + // Hack - Disable Chrome save password + if (this.autocomplete) { + this.readOnlyValue = "readonly"; } }, methods: { @@ -69,6 +89,13 @@ export default { }, hideInput() { this.visibility = "password"; + }, + + // Hack - Disable Chrome save password + removeReadOnly() { + if (this.autocomplete) { + this.readOnlyValue = false; + } } } } diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 8a79dba58..080fb859e 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -40,7 +40,7 @@