diff --git a/packages/lib-user/src/components/shared/GroupForm/GroupForm.js b/packages/lib-user/src/components/shared/GroupForm/GroupForm.js index 2ba79c1695..4e5aa890e9 100644 --- a/packages/lib-user/src/components/shared/GroupForm/GroupForm.js +++ b/packages/lib-user/src/components/shared/GroupForm/GroupForm.js @@ -56,6 +56,7 @@ function GroupForm({ const [value, setValue] = useState(defaultValue) const statsVisibilityOptions = value.visibility === 'Private' ? PRIVATE_STATS_VISIBILITY : PUBLIC_STATS_VISIBILITY + const selectedVisibilityOption = statsVisibilityOptions.find((option) => option.value === value.stats_visibility) useEffect(() => { setValue(defaultValue) @@ -64,11 +65,12 @@ function GroupForm({ return (
{ + const selectedVisibilityOption = statsVisibilityOptions.find((option) => option.label === nextValue.stats_visibility) + let stats_visibility = selectedVisibilityOption ? selectedVisibilityOption.value : value.stats_visibility if (nextValue.visibility !== value.visibility) { - const statsVisibility = nextValue.visibility === 'Private' ? 'private_agg_only' : 'public_agg_only' - nextValue.stats_visibility = statsVisibility + stats_visibility = nextValue.visibility === 'Private' ? 'private_agg_only' : 'public_agg_only' } - setValue(nextValue) + setValue({ ...nextValue, stats_visibility }) }} onSubmit={handleSubmit} value={value} @@ -151,10 +153,10 @@ function GroupForm({ shared > MainContent', function () { it('should show "ALL PROJECTS" as the selected project', function () { render() - const projectSelect = screen.getByRole('textbox', { name: 'project-select' }) + const projectSelectMenu = screen.getByRole('button', { name: 'Select project; Selected: ALL PROJECTS' }) + const projectSelect = screen.getByRole('textbox', { name: 'Select project, ALL PROJECTS' }) + expect(projectSelectMenu).to.be.ok() expect(projectSelect).to.be.ok() expect(projectSelect.value).to.equal('ALL PROJECTS') }) it('should show "LAST 7 DAYS" as the selected date range', function () { render() - const dateRangeSelect = screen.getByRole('textbox', { name: 'date-range-select' }) + const dateRangeSelectMenu = screen.getByRole('button', { name: 'Select date range; Selected: LAST 7 DAYS' }) + const dateRangeSelect = screen.getByRole('textbox', { name: 'Select date range, LAST 7 DAYS' }) + expect(dateRangeSelectMenu).to.be.ok() expect(dateRangeSelect).to.be.ok() expect(dateRangeSelect.value).to.equal('LAST 7 DAYS') }) diff --git a/packages/lib-user/src/components/shared/Select/Select.js b/packages/lib-user/src/components/shared/Select/Select.js index e7c5314a86..9d8f620527 100644 --- a/packages/lib-user/src/components/shared/Select/Select.js +++ b/packages/lib-user/src/components/shared/Select/Select.js @@ -18,7 +18,8 @@ function Select({ name = '', handleChange = DEFAULT_HANDLER, options = [], - value = DEFAULT_VALUE + value = DEFAULT_VALUE, + ...props }) { const [selected, setSelected] = useState(value) @@ -34,14 +35,15 @@ function Select({ return ( handleSelect(option)} options={options} size='medium' - value={selected} + value={selected.label} + valueKey={{ key: 'label', reduce: true }} + {...props} /> ) diff --git a/packages/lib-user/src/translations/en.json b/packages/lib-user/src/translations/en.json index 1eaf1aed3d..95233d305e 100644 --- a/packages/lib-user/src/translations/en.json +++ b/packages/lib-user/src/translations/en.json @@ -117,6 +117,8 @@ "error": "There was an error.", "hoursTip": "Hours are calculated based on the start and end times of your classification efforts. Hours do not reflect your time spent on Talk.", "noData": "No data found.", + "selectDateRange": "Select date range", + "selectProject": "Select project", "start": "Start by <0>classifying a project now, or change the date range.", "tabContents": "Tab Contents" },