From 0a1daf353ae16de78c041573bd0afcb872f22313 Mon Sep 17 00:00:00 2001 From: jasquat Date: Tue, 9 May 2023 09:30:09 -0400 Subject: [PATCH] Revert "Revert "make all browsers act the same way on our site w/ jasquat"" This reverts commit 7c4b7b71b7c8ef50f748b8f616223d833079f88b. --- .../src/themes/carbon/SelectWidget/SelectWidget.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spiffworkflow-frontend/src/themes/carbon/SelectWidget/SelectWidget.tsx b/spiffworkflow-frontend/src/themes/carbon/SelectWidget/SelectWidget.tsx index 7e644055..6f55ef1b 100644 --- a/spiffworkflow-frontend/src/themes/carbon/SelectWidget/SelectWidget.tsx +++ b/spiffworkflow-frontend/src/themes/carbon/SelectWidget/SelectWidget.tsx @@ -56,6 +56,17 @@ function SelectWidget({ errorMessageForField = rawErrors[0]; } + // ok. so in safari, the select widget showed the first option, whereas in chrome it forced you to select an option. + // this change causes chrome to also show the first option. now all browsers are consistent on our site. you no longer have to select anything. + // setting the value prop causes it to show the first option. + // calling onChange actually gets it set in the form data. + if (value === undefined) { + if (enumOptions) { + value = enumOptions[0].value; + onChange(value); + } + } + // maybe use placeholder somehow. it was previously jammed into the helperText field, // but allowing ui:help to grab that spot seems much more appropriate.