From 9ccb0d90fa31e2c7fb61e40ff4b27d2604013772 Mon Sep 17 00:00:00 2001
From: killij <51908793+killij@users.noreply.github.com>
Date: Fri, 12 Jan 2024 11:47:36 +0000
Subject: [PATCH] fix: Enter key does not submit form, now triggers the sort
 order which performs the submit (#369)

---
 .../Views/SearchResources/SearchResources.cshtml         | 2 +-
 Childrens-Social-Care-CPD/wwwroot/javascript/search.js   | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
 create mode 100644 Childrens-Social-Care-CPD/wwwroot/javascript/search.js

diff --git a/Childrens-Social-Care-CPD/Views/SearchResources/SearchResources.cshtml b/Childrens-Social-Care-CPD/Views/SearchResources/SearchResources.cshtml
index eada999a..facfbb0c 100644
--- a/Childrens-Social-Care-CPD/Views/SearchResources/SearchResources.cshtml
+++ b/Childrens-Social-Care-CPD/Views/SearchResources/SearchResources.cshtml
@@ -66,5 +66,5 @@
 </div>
 
 @section Scripts {
-    <script src="~/javascript/search-sort.js" asp-append-version="true"></script>
+    <script src="~/javascript/search.js" asp-append-version="true"></script>
 }
\ No newline at end of file
diff --git a/Childrens-Social-Care-CPD/wwwroot/javascript/search.js b/Childrens-Social-Care-CPD/wwwroot/javascript/search.js
new file mode 100644
index 00000000..04a01a0b
--- /dev/null
+++ b/Childrens-Social-Care-CPD/wwwroot/javascript/search.js
@@ -0,0 +1,9 @@
+document.addEventListener("DOMContentLoaded", function () {
+    const input = document.getElementById('searchTermInput')
+    input.addEventListener("keydown", (e) => {
+        if (e.key === "Enter") {
+            document.getElementById('sortOrder').value = 2
+            return false
+        }
+    })
+})
\ No newline at end of file