From 19e73a4263d05cba07157d7e6a7f7f971745c662 Mon Sep 17 00:00:00 2001
From: Matjaž Črnko <m.crnko@txt.si>
Date: Mon, 22 Jan 2024 18:25:48 +0100
Subject: fix: SelectField - cleaner approach for Autocomplete value handling

---
 modern/src/common/components/SelectField.jsx | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

(limited to 'modern/src/common/components/SelectField.jsx')

diff --git a/modern/src/common/components/SelectField.jsx b/modern/src/common/components/SelectField.jsx
index bc0571d5..920c2640 100644
--- a/modern/src/common/components/SelectField.jsx
+++ b/modern/src/common/components/SelectField.jsx
@@ -14,7 +14,6 @@ const SelectField = ({
   onChange,
   endpoint,
   data,
-  keyField = 'id',
   keyGetter = (item) => item.id,
   titleGetter = (item) => item.name,
 }) => {
@@ -22,7 +21,7 @@ const SelectField = ({
 
   const getOptionLabel = (option) => {
     if (typeof option !== 'object') {
-      option = items.find(obj => keyField ? obj[keyField] === option : obj === option);
+      option = items.find(obj => keyGetter(obj) === option);
     }
     return option ? titleGetter(option) : '';
   }
-- 
cgit v1.2.3

