Skip to content

Commit ee712d9

Browse files
committed
use shorter title
1 parent fee2b45 commit ee712d9

File tree

1 file changed

+6
-8
lines changed
  • packages/docusaurus-theme-classic/src/theme/ColorModeToggle

1 file changed

+6
-8
lines changed

packages/docusaurus-theme-classic/src/theme/ColorModeToggle/index.tsx

+6-8
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function getColorModeLabel(colorMode: ColorMode | null): string {
6565
}
6666
}
6767

68-
function getColorModeTitle(colorMode: ColorMode | null) {
68+
function getColorModeAriaLabel(colorMode: ColorMode | null) {
6969
return translate(
7070
{
7171
message: 'Switch between dark and light mode (currently {mode})',
@@ -110,9 +110,6 @@ function ColorModeToggle({
110110
onChange,
111111
}: Props): ReactNode {
112112
const isBrowser = useIsBrowser();
113-
114-
const title = getColorModeTitle(value);
115-
116113
return (
117114
<div className={clsx(styles.toggle, className)}>
118115
<button
@@ -127,16 +124,17 @@ function ColorModeToggle({
127124
onChange(getNextColorMode(value, respectPrefersColorScheme))
128125
}
129126
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
131132

132133
// aria-live disabled on purpose - This is annoying because:
133134
// - without this attribute, VoiceOver doesn't announce on button enter
134135
// - with this attribute, VoiceOver announces twice on ctrl+opt+space
135136
// - with this attribute, NVDA announces many times
136137
// aria-live="polite"
137-
138-
// Title leads to double announcements in NVDA
139-
// title={title}
140138
>
141139
<CurrentColorModeIcon />
142140
</button>

0 commit comments

Comments
 (0)