fix(frontend): language switcher focus styles and debug logs
This commit is contained in:
parent
798031420e
commit
e845ba63c8
2 changed files with 12 additions and 4 deletions
|
|
@ -24,7 +24,7 @@ export function LanguageSwitcher() {
|
|||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="sm" className="w-12 px-0 gap-2">
|
||||
<Button variant="ghost" size="sm" className="w-12 px-0 gap-2 focus-visible:ring-0 focus-visible:ring-offset-0">
|
||||
<Globe className="h-4 w-4" />
|
||||
<span className="sr-only">Toggle language</span>
|
||||
</Button>
|
||||
|
|
@ -33,8 +33,11 @@ export function LanguageSwitcher() {
|
|||
{locales.map((l) => (
|
||||
<DropdownMenuItem
|
||||
key={l.code}
|
||||
onClick={() => setLocale(l.code)}
|
||||
className="flex items-center gap-2 cursor-pointer"
|
||||
onClick={() => {
|
||||
console.log(`[LanguageSwitcher] Clicking ${l.code}`);
|
||||
setLocale(l.code);
|
||||
}}
|
||||
className="flex items-center gap-2 cursor-pointer focus:outline-none focus:bg-accent focus:text-accent-foreground"
|
||||
>
|
||||
<span className="text-lg">{l.flag}</span>
|
||||
<span>{l.name}</span>
|
||||
|
|
|
|||
|
|
@ -39,7 +39,12 @@ const getInitialLocale = (): Locale => {
|
|||
};
|
||||
|
||||
export function I18nProvider({ children }: { children: ReactNode }) {
|
||||
const [locale, setLocale] = useState<Locale>(getInitialLocale);
|
||||
const [locale, setLocaleState] = useState<Locale>(getInitialLocale);
|
||||
|
||||
const setLocale = (newLocale: Locale) => {
|
||||
console.log(`[I18n] Setting locale to: ${newLocale}`);
|
||||
setLocaleState(newLocale);
|
||||
};
|
||||
|
||||
const t = useCallback((key: string, params?: Record<string, string | number>): string => {
|
||||
const keys = key.split('.');
|
||||
|
|
|
|||
Loading…
Reference in a new issue