Skip to content

Commit

Permalink
Fix bug when forms with data-ga4-form-no-answer-undefined are submitted
Browse files Browse the repository at this point in the history
When data-ga4-form-no-answer-undefined exists, it sets the text to undefined. However straight after that, it was trying to call .toLowerCase(), so the GA4 JS crashes on submit of these search forms.
  • Loading branch information
AshGDS committed Oct 26, 2023
1 parent 7fe224b commit a780c9c
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
var formData = this.getInputValues(formInputs)
data.text = data.text || this.combineGivenAnswers(formData) || this.useFallbackValue

if (data.action === 'search') {
if (data.action === 'search' && data.text) {
data.text = data.text.toLowerCase()
data.text = window.GOVUK.analyticsGa4.core.trackFunctions.removeLinesAndExtraSpaces(data.text)
}
Expand Down

0 comments on commit a780c9c

Please sign in to comment.