File tree 1 file changed +6
-8
lines changed
packages/docusaurus-theme-classic/src/theme/ColorModeToggle
1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ function getColorModeLabel(colorMode: ColorMode | null): string {
65
65
}
66
66
}
67
67
68
- function getColorModeTitle ( colorMode : ColorMode | null ) {
68
+ function getColorModeAriaLabel ( colorMode : ColorMode | null ) {
69
69
return translate (
70
70
{
71
71
message : 'Switch between dark and light mode (currently {mode})' ,
@@ -110,9 +110,6 @@ function ColorModeToggle({
110
110
onChange,
111
111
} : Props ) : ReactNode {
112
112
const isBrowser = useIsBrowser ( ) ;
113
-
114
- const title = getColorModeTitle ( value ) ;
115
-
116
113
return (
117
114
< div className = { clsx ( styles . toggle , className ) } >
118
115
< button
@@ -127,16 +124,17 @@ function ColorModeToggle({
127
124
onChange ( getNextColorMode ( value , respectPrefersColorScheme ) )
128
125
}
129
126
disabled = { ! isBrowser }
130
- aria-label = { title }
127
+ title = { getColorModeLabel ( value ) }
128
+ aria-label = { getColorModeAriaLabel ( value ) }
129
+
130
+ // For accessibility decisions
131
+ // See https://github.com/facebook/docusaurus/issues/7667#issuecomment-2724401796
131
132
132
133
// aria-live disabled on purpose - This is annoying because:
133
134
// - without this attribute, VoiceOver doesn't announce on button enter
134
135
// - with this attribute, VoiceOver announces twice on ctrl+opt+space
135
136
// - with this attribute, NVDA announces many times
136
137
// aria-live="polite"
137
-
138
- // Title leads to double announcements in NVDA
139
- // title={title}
140
138
>
141
139
< CurrentColorModeIcon />
142
140
</ button >
You can’t perform that action at this time.
0 commit comments