Skip to content

Commit 3e2e8a5

Browse files
committed
fix: actually persist selected locale via cmd palette
1 parent 218de39 commit 3e2e8a5

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

app/composables/useCommandPaletteGlobalCommands.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ export function useCommandPaletteGlobalCommands({
152152
activeLabel: code === locale.value ? t('command_palette.current') : null,
153153
action: runThenAnnounce(
154154
async () => {
155+
// TODO(serhalp): Extract a shared composable that wraps setLocale to always persist to settings
156+
settings.value.selectedLocale = code
155157
await setLocale(code)
156158
},
157159
() =>

test/nuxt/composables/use-command-palette-commands.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,24 @@ describe('useCommandPaletteCommands', () => {
399399
wrapper.unmount()
400400
})
401401

402+
it('persists the selected locale to settings when changing language via the palette', async () => {
403+
const { wrapper, flatCommands } = await captureCommandPalette({
404+
view: 'languages',
405+
})
406+
const { settings } = useSettings()
407+
expect(settings.value.selectedLocale).toBeNull()
408+
409+
const frCommand = flatCommands.value.find(command => command.id === 'locale:fr-FR')
410+
expect(frCommand).toBeTruthy()
411+
await frCommand?.action?.()
412+
413+
expect(settings.value.selectedLocale).toBe('fr-FR')
414+
415+
// Clean up
416+
settings.value.selectedLocale = null
417+
wrapper.unmount()
418+
})
419+
402420
it('does not inject version overrides into unrelated palette subviews', async () => {
403421
const { wrapper, groupedCommands, flatCommands } = await captureCommandPalette({
404422
view: 'languages',

0 commit comments

Comments
 (0)