From fd4d43f44153667e8b12b3b32c8e926ce56566e0 Mon Sep 17 00:00:00 2001 From: jasquat Date: Tue, 9 May 2023 09:30:09 -0400 Subject: [PATCH 1/6] Revert "Revert "make all browsers act the same way on our site w/ jasquat"" This reverts commit 13f51f9f828aa24c9afa6588903d3eb5dea64016. --- .../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. From c77a65bdda3e6ec970126c57c88866f49bc94e15 Mon Sep 17 00:00:00 2001 From: jasquat Date: Tue, 9 May 2023 11:55:59 -0400 Subject: [PATCH 2/6] try adding a blank option for form selects w/ burnettk --- spiffworkflow-frontend/src/routes/TaskShow.tsx | 1 + .../src/themes/carbon/SelectWidget/SelectWidget.tsx | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/spiffworkflow-frontend/src/routes/TaskShow.tsx b/spiffworkflow-frontend/src/routes/TaskShow.tsx index 3cddc676..e8ec096d 100644 --- a/spiffworkflow-frontend/src/routes/TaskShow.tsx +++ b/spiffworkflow-frontend/src/routes/TaskShow.tsx @@ -267,6 +267,7 @@ export default function TaskShow() { formData: any, errors: any ) => { + console.log('errors', errors); if ('properties' in jsonSchema) { Object.keys(jsonSchema.properties).forEach((propertyKey: string) => { const propertyMetadata = jsonSchema.properties[propertyKey]; diff --git a/spiffworkflow-frontend/src/themes/carbon/SelectWidget/SelectWidget.tsx b/spiffworkflow-frontend/src/themes/carbon/SelectWidget/SelectWidget.tsx index 6f55ef1b..10204145 100644 --- a/spiffworkflow-frontend/src/themes/carbon/SelectWidget/SelectWidget.tsx +++ b/spiffworkflow-frontend/src/themes/carbon/SelectWidget/SelectWidget.tsx @@ -60,11 +60,8 @@ function SelectWidget({ // 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); - } + if (enumOptions && enumOptions[0].value !== '') { + enumOptions.unshift({ value: '', label: '' }); } // maybe use placeholder somehow. it was previously jammed into the helperText field, From 62eb5ccb6d70e038558776973e15a0d4dd1544d3 Mon Sep 17 00:00:00 2001 From: burnettk Date: Tue, 9 May 2023 12:41:09 -0400 Subject: [PATCH 3/6] make safari act a bit more like other browsers by adding a blank option w/ jasquat --- .../carbon/SelectWidget/SelectWidget.tsx | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/spiffworkflow-frontend/src/themes/carbon/SelectWidget/SelectWidget.tsx b/spiffworkflow-frontend/src/themes/carbon/SelectWidget/SelectWidget.tsx index 10204145..436b301e 100644 --- a/spiffworkflow-frontend/src/themes/carbon/SelectWidget/SelectWidget.tsx +++ b/spiffworkflow-frontend/src/themes/carbon/SelectWidget/SelectWidget.tsx @@ -19,7 +19,8 @@ function SelectWidget({ placeholder, rawErrors = [], }: WidgetProps) { - const { enumOptions, enumDisabled } = options; + const { enumOptions } = options; + let { enumDisabled } = options; const emptyValue = multiple ? [] : ''; @@ -57,11 +58,33 @@ function SelectWidget({ } // 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 (enumOptions && enumOptions[0].value !== '') { - enumOptions.unshift({ value: '', label: '' }); + // this change causes causes safari to act a little bit more like chrome, but it's different because we are actually adding + // an element to the dropdown. + // + // https://stackoverflow.com/a/7944490/6090676 safari detection + let isSafari = false; + const ua = navigator.userAgent.toLowerCase(); + if (ua.indexOf('safari') != -1) { + if (ua.indexOf('chrome') === -1) { + isSafari = true; + } + } + + if (isSafari) { + if (enumOptions && enumOptions[0].value !== '') { + enumOptions.unshift({ + value: '', + label: '', + }); + } + // enumDisabled is a list of values for which the option should be disabled. + // we don't really want users to select the fake empty option we are creating here. + // they cannot select it in chrome, after all. + // google is always right. https://news.ycombinator.com/item?id=35862041 + if (enumDisabled === undefined) { + enumDisabled = []; + } + enumDisabled.push(''); } // maybe use placeholder somehow. it was previously jammed into the helperText field, From a385497c33fce26fd01983227b69dbdd78d05725 Mon Sep 17 00:00:00 2001 From: jbirddog <100367399+jbirddog@users.noreply.github.com> Date: Tue, 9 May 2023 12:55:49 -0400 Subject: [PATCH 4/6] Rename Save as draft to Close, add tooltip (#246) --- .../cypress/pilot/NDR_PP1/initiaterequest.cy.js | 4 ++-- spiffworkflow-frontend/src/routes/TaskShow.tsx | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/spiffworkflow-frontend/cypress/pilot/NDR_PP1/initiaterequest.cy.js b/spiffworkflow-frontend/cypress/pilot/NDR_PP1/initiaterequest.cy.js index 63172bde..d85e337a 100644 --- a/spiffworkflow-frontend/cypress/pilot/NDR_PP1/initiaterequest.cy.js +++ b/spiffworkflow-frontend/cypress/pilot/NDR_PP1/initiaterequest.cy.js @@ -405,7 +405,7 @@ describe.only('Initiate a Request - Without Files', () => { cy.get('#root_item_1_unit_price').type('4500'); cy.get('button') - .contains(/^Save as draft$/) + .contains(/^Close$/) .click(); //cy.get('button') @@ -505,7 +505,7 @@ describe.only('Initiate a Request - Without Files', () => { cy.get('.cds--text-area__wrapper').find('#root').type('2021 Newest HP 17.3 inch FHD Laptop, AMD Ryzen 5 5500U 6core(Beat i7-1160G7, up to 4.0GHz),16GB RAM, 1TB PCIe SSD, Bluetooth 4.2, WiFi, HDMI, USB-A&C, Windows 10 S, w/Ghost Manta Accessories, Silver\nhttps://www.amazon.com/HP-i7-11G7-Bluetooth-Windows'); cy.get('button') - .contains(/^Save as draft$/) + .contains(/^Close$/) .click(); // cy.get('button') diff --git a/spiffworkflow-frontend/src/routes/TaskShow.tsx b/spiffworkflow-frontend/src/routes/TaskShow.tsx index e8ec096d..7ceacb4c 100644 --- a/spiffworkflow-frontend/src/routes/TaskShow.tsx +++ b/spiffworkflow-frontend/src/routes/TaskShow.tsx @@ -348,20 +348,21 @@ export default function TaskShow() { if (task.state === 'READY') { let submitButtonText = 'Submit'; - let saveAsDraftButton = null; + let closeButton = null; if (task.typename === 'ManualTask') { submitButtonText = 'Continue'; } else if (task.typename === 'UserTask') { - saveAsDraftButton = ( + closeButton = ( ); } @@ -370,7 +371,7 @@ export default function TaskShow() { - {saveAsDraftButton} + {closeButton} <> {task.signal_buttons.map((signal) => (