From de22f16048790de8f8b40de8d0f6e1cc923720af Mon Sep 17 00:00:00 2001 From: Matthew Foster Date: Wed, 12 Jun 2024 10:51:00 -0700 Subject: [PATCH] populate ROR immediately if only once response is returned from org query. Switch to using exact match in query so that spaces are handled correctly --- src/components/FormComponents/ContactEditor.jsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/FormComponents/ContactEditor.jsx b/src/components/FormComponents/ContactEditor.jsx index cfde2a35..b8a265bb 100644 --- a/src/components/FormComponents/ContactEditor.jsx +++ b/src/components/FormComponents/ContactEditor.jsx @@ -67,9 +67,15 @@ const ContactEditor = ({ ) { if (mounted.current) setRorSearchActive(false); } else { - fetch(`https://api.ror.org/organizations?query=${newInputValue}`) + fetch(`https://api.ror.org/organizations?query="${newInputValue}"`) .then((response) => response.json()) - .then((response) => {if (mounted.current) setRorOptions(response.items)}) + .then((response) => { + if (mounted.current){ + setRorOptions(response.items)} + if (response.number_of_results === 1){ + updateContactRor(response.items[0]); + } + }) .then(() => {if (mounted.current) setRorSearchActive(false)}); } }