From e034fad4f3f76a95394741335990c44c7f77a54e Mon Sep 17 00:00:00 2001 From: Lori Bailey <44073106+elceebee@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:33:57 +0000 Subject: [PATCH] Only warn if editing large text areas This was causing interruptions on pages with just brief descriptions, not all of which were even required. --- app/frontend/packs/warn-on-unsaved-changes.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/frontend/packs/warn-on-unsaved-changes.js b/app/frontend/packs/warn-on-unsaved-changes.js index 9829336bfb1..6d0754cfe63 100644 --- a/app/frontend/packs/warn-on-unsaved-changes.js +++ b/app/frontend/packs/warn-on-unsaved-changes.js @@ -6,7 +6,9 @@ const getCompleteSectionCheckbox = () => { } const getTextArea = () => { - return document.querySelector('.govuk-textarea') + const $textAreas = document.querySelectorAll('.govuk-textarea') + + return [].filter.call($textAreas, ($textArea) => $textArea.rows > 5)[0] } const getFirstEnhanceableForm = () => {