So let's say you have:
- a button that controls
time period - the button opens a dialog to select the time period
- the button changes text base on the selection (ie "3 days", "1 week", etc)
I want to label the button, but if I add aria-label="time period" to the button, then the current value (ie "3 days") is never read, since the aria-label overrides any current text.
So what is the best solution for both labelling the button, and indicating its current value, to a screenreader?
Sounds like the misuse of a button. You want it to indicate some action and you want it to display a value. That's not what a button is for. It should perform an action.
The value of the time period should be a separate DOM element. Perhaps plain text with a label.
When a screen reader user tabs to the button, they'll hear "Change time period, button, time period: 3 days".
Note, however, that
aria-describedbyspecifies the description of the element and the user could turn off description announcements (sometimes called hints) in the screen reader, in which case they wouldn't hear the time period value, although they could navigate back up to the time period using other screen reader keyboard shortcuts.