aboutsummaryrefslogtreecommitdiff
path: root/modern/src/common
diff options
context:
space:
mode:
authorMatjaž Črnko <m.crnko@txt.si>2024-01-22 18:25:48 +0100
committerMatjaž Črnko <m.crnko@txt.si>2024-01-22 18:25:48 +0100
commit19e73a4263d05cba07157d7e6a7f7f971745c662 (patch)
treec0af4558f6a1a84cdc683f1d0d1401b5fe09f63b /modern/src/common
parent2bd044ecf9fa456e168057acc513bd3b4582d0c6 (diff)
downloadtrackermap-web-19e73a4263d05cba07157d7e6a7f7f971745c662.tar.gz
trackermap-web-19e73a4263d05cba07157d7e6a7f7f971745c662.tar.bz2
trackermap-web-19e73a4263d05cba07157d7e6a7f7f971745c662.zip
fix: SelectField - cleaner approach for Autocomplete value handling
Diffstat (limited to 'modern/src/common')
-rw-r--r--modern/src/common/components/SelectField.jsx3
1 files changed, 1 insertions, 2 deletions
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) : '';
}