fix(admin): drop ML copy-from locale chrome (quick-261006-s0v)

Copy overwrote the active locale with the other locale's often-empty string, so the editor went blank. Keep a single synchronized locale picker.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-10-06 20:12:47 +02:00
parent ba4427360b
commit 2f03128a58
6 changed files with 13 additions and 76 deletions

View File

@@ -15,12 +15,10 @@ const locales = computed(() => {
return codes && codes.length > 0 ? [...codes] : []
})
const activeLocale = ref(locales.value[0] ?? 'en')
const copyFrom = ref('')
const labelledBy = computed(() => `${props.controlId}-label`)
const editorId = computed(() => `${props.controlId}-editor`)
const activeText = computed(() => values.value[activeLocale.value] ?? '')
const otherLocales = computed(() => locales.value.filter((code) => code !== activeLocale.value))
const markdownField = computed(() => ({ ...props.field, type: 'markdown' }))
function setLocale(locale: string) {
@@ -28,9 +26,6 @@ function setLocale(locale: string) {
return
}
activeLocale.value = locale
if (!copyFrom.value || copyFrom.value === locale) {
copyFrom.value = otherLocales.value[0] ?? ''
}
}
function onLocaleInput(event: Event) {
@@ -43,14 +38,6 @@ function onText(text: string) {
emit('update:modelValue', { ...values.value, [activeLocale.value]: text })
}
function copyLocale() {
const from = copyFrom.value
if (!from || from === activeLocale.value) {
return
}
emit('update:modelValue', { ...values.value, [activeLocale.value]: values.value[from] ?? '' })
}
function onBroadcast(event: Event) {
const locale = (event as CustomEvent<string>).detail
if (typeof locale === 'string' && locale !== '') {
@@ -60,7 +47,6 @@ function onBroadcast(event: Event) {
onMounted(() => {
window.addEventListener(ML_LOCALE_CHANGE, onBroadcast)
copyFrom.value = otherLocales.value[0] ?? ''
})
onUnmounted(() => {
window.removeEventListener(ML_LOCALE_CHANGE, onBroadcast)
@@ -79,25 +65,6 @@ onUnmounted(() => {
>
<option v-for="code in locales" :key="code" :value="code">{{ code }}</option>
</select>
<select
v-if="otherLocales.length > 0"
data-ml-copy-from
class="rounded-control border border-border-strong bg-surface px-2 py-1 text-[13px]"
:value="copyFrom"
aria-label="Copy from locale"
@change="copyFrom = ($event.target as HTMLSelectElement).value"
>
<option v-for="code in otherLocales" :key="code" :value="code">{{ code }}</option>
</select>
<button
v-if="otherLocales.length > 0"
type="button"
data-ml-copy
class="rounded-pager px-2 py-1 text-[13px] text-muted hover:bg-hover hover:text-text"
@click="copyLocale"
>
Copy
</button>
</div>
<MarkdownField
:field="markdownField"

View File

@@ -15,21 +15,16 @@ const locales = computed(() => {
return codes && codes.length > 0 ? [...codes] : []
})
const activeLocale = ref(locales.value[0] ?? 'en')
const copyFrom = ref('')
const labelledBy = computed(() => `${props.controlId}-label`)
const editorId = computed(() => `${props.controlId}-editor`)
const activeText = computed(() => values.value[activeLocale.value] ?? '')
const otherLocales = computed(() => locales.value.filter((code) => code !== activeLocale.value))
function setLocale(locale: string) {
if (!locale) {
return
}
activeLocale.value = locale
if (!copyFrom.value || copyFrom.value === locale) {
copyFrom.value = otherLocales.value[0] ?? ''
}
}
function onLocaleInput(event: Event) {
@@ -42,14 +37,6 @@ function onText(text: string) {
emit('update:modelValue', { ...values.value, [activeLocale.value]: text })
}
function copyLocale() {
const from = copyFrom.value
if (!from || from === activeLocale.value) {
return
}
emit('update:modelValue', { ...values.value, [activeLocale.value]: values.value[from] ?? '' })
}
function onBroadcast(event: Event) {
const locale = (event as CustomEvent<string>).detail
if (typeof locale === 'string' && locale !== '') {
@@ -59,7 +46,6 @@ function onBroadcast(event: Event) {
onMounted(() => {
window.addEventListener(ML_LOCALE_CHANGE, onBroadcast)
copyFrom.value = otherLocales.value[0] ?? ''
})
onUnmounted(() => {
window.removeEventListener(ML_LOCALE_CHANGE, onBroadcast)
@@ -78,25 +64,6 @@ onUnmounted(() => {
>
<option v-for="code in locales" :key="code" :value="code">{{ code }}</option>
</select>
<select
v-if="otherLocales.length > 0"
data-ml-copy-from
class="rounded-control border border-border-strong bg-surface px-2 py-1 text-[13px]"
:value="copyFrom"
aria-label="Copy from locale"
@change="copyFrom = ($event.target as HTMLSelectElement).value"
>
<option v-for="code in otherLocales" :key="code" :value="code">{{ code }}</option>
</select>
<button
v-if="otherLocales.length > 0"
type="button"
data-ml-copy
class="rounded-pager px-2 py-1 text-[13px] text-muted hover:bg-hover hover:text-text"
@click="copyLocale"
>
Copy
</button>
</div>
<TextField
:field="{ ...field, type: 'text' }"