Skip to content

Commit

Permalink
fix(a11y): user select menu labels
Browse files Browse the repository at this point in the history
- fix 'Selected: [object Object]' in the labels for user dropdown menus.
- add plain English labels for the project and date range menus.
  • Loading branch information
eatyourgreens committed Jan 8, 2025
1 parent fd585a1 commit 34f6999
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,15 @@ function MainContent({
<Select
id='project-select'
name='project-select'
aria-label={t('MainContent.selectProject')}
handleChange={handleProjectSelect}
options={projectOptions}
value={selectedProjectOption}
/>
<Select
id='date-range-select'
name='date-range-select'
aria-label={t('MainContent.selectDateRange')}
handleChange={handleDateRangeSelect}
options={dateRangeOptions}
value={selectedDateRangeOption}
Expand Down
8 changes: 5 additions & 3 deletions packages/lib-user/src/components/shared/Select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ function Select({
name = '',
handleChange = DEFAULT_HANDLER,
options = [],
value = DEFAULT_VALUE
value = DEFAULT_VALUE,
...props
}) {
const [selected, setSelected] = useState(value)

Expand All @@ -34,14 +35,15 @@ function Select({
return (
<ThemeContext.Extend value={selectTheme}>
<StyledSelect
a11yTitle={name}
id={id}
name={name}
labelKey='label'
onChange={({ option }) => handleSelect(option)}
options={options}
size='medium'
value={selected}
value={selected.label}
valueKey={{ key: 'label', reduce: true }}
{...props}
/>
</ThemeContext.Extend>
)
Expand Down
2 changes: 2 additions & 0 deletions packages/lib-user/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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</0> now, or change the date range.",
"tabContents": "Tab Contents"
},
Expand Down

0 comments on commit 34f6999

Please sign in to comment.