From 132f39e2de2446a16ccfc18dbc65ba955527b6b4 Mon Sep 17 00:00:00 2001 From: Katie Date: Mon, 17 Oct 2022 11:27:23 -0400 Subject: [PATCH] CSR-762 Rename and move around GA logic --- src/App.vue | 6 ++-- .../base-input-button/base-input-button.vue | 8 ++--- src/helpers/analytics-helper.js | 34 ------------------- src/helpers/input-button-focus-helper.js | 34 +++++++++++++++++++ 4 files changed, 41 insertions(+), 41 deletions(-) delete mode 100644 src/helpers/analytics-helper.js create mode 100644 src/helpers/input-button-focus-helper.js diff --git a/src/App.vue b/src/App.vue index e43e85c84..7c7bfd559 100644 --- a/src/App.vue +++ b/src/App.vue @@ -5,17 +5,17 @@ name="route-fade" mode="out-in"> - + diff --git a/src/common-components/base-input-button/base-input-button.vue b/src/common-components/base-input-button/base-input-button.vue index 71da03d85..1fb1f9bc5 100644 --- a/src/common-components/base-input-button/base-input-button.vue +++ b/src/common-components/base-input-button/base-input-button.vue @@ -26,7 +26,7 @@ import { useField } from "vee-validate"; import { toRef } from "vue"; import { queryStrings } from "@/constants/query-strings"; -import { handleInputFocus, handleInputBlur } from "@/helpers/analytics-helper"; +import { handleButtonComponentFocus, handleInputComponentBlur } from "@/helpers/input-button-focus-helper"; import { inputButtonProps } from "@/common-components/base-input-button/button-functionality-props"; export default { @@ -100,14 +100,14 @@ export default { this.$emit("update:modelValue", this.valueToEmit); }, handleFocus() { - handleInputFocus({ + handleButtonComponentFocus({ groupName: this.groupName, }); }, handleBlur() { - handleInputBlur({ + handleInputComponentBlur({ groupName: this.groupName, - onFocusCallback: this.handlePushClickEventToGACheck, + onButtonQuestionLostFocusCallback: this.handlePushClickEventToGACheck, }); }, handlePushClickEventToGACheck(source) { diff --git a/src/helpers/analytics-helper.js b/src/helpers/analytics-helper.js deleted file mode 100644 index b03d86191..000000000 --- a/src/helpers/analytics-helper.js +++ /dev/null @@ -1,34 +0,0 @@ -let lastFocusedInputGroupName = ""; -let onFocusCallback = null; - -const handleChildFocus = (e) => { - const targetType = e.target.type; - if (targetType !== "radio" && targetType !== "checkbox") { - handleInputFocus({ - groupName: null, - }); - } -} - -const handleInputFocus = (e) => { - if ( - e && - lastFocusedInputGroupName !== e.groupName && - onFocusCallback - ) { - onFocusCallback(); - } -} - -const handleInputBlur = (e) => { - if (e) { - lastFocusedInputGroupName = e.groupName; - onFocusCallback = e.onFocusCallback; - } -} - -export { - handleChildFocus, - handleInputFocus, - handleInputBlur -} \ No newline at end of file diff --git a/src/helpers/input-button-focus-helper.js b/src/helpers/input-button-focus-helper.js new file mode 100644 index 000000000..77bd175ad --- /dev/null +++ b/src/helpers/input-button-focus-helper.js @@ -0,0 +1,34 @@ +let lastFocusedInputGroupName = ""; +let onButtonQuestionLostFocusCallback = null; + +const handleAnyComponentFocus = (e) => { + const targetType = e.target.type; + if (targetType !== "radio" && targetType !== "checkbox") { + invokeButtonQuestionLostFocusCallback(); + } +}; + +const handleButtonComponentFocus = (e) => { + if (e && lastFocusedInputGroupName !== e.groupName) { + invokeButtonQuestionLostFocusCallback(); + } +}; + +const handleInputComponentBlur = (e) => { + if (e) { + lastFocusedInputGroupName = e.groupName; + onButtonQuestionLostFocusCallback = e.onButtonQuestionLostFocusCallback; + } +}; + +const invokeButtonQuestionLostFocusCallback = () => { + if (onButtonQuestionLostFocusCallback) { + onButtonQuestionLostFocusCallback(); + } +}; + +export { + handleAnyComponentFocus, + handleButtonComponentFocus, + handleInputComponentBlur, +};