fix: fix font selector view value (#6453)

This commit is contained in:
Shiyun Hua
2026-01-09 22:28:02 +08:00
committed by GitHub
parent d8755475be
commit 7fb8ab1b3c
@@ -45,15 +45,19 @@ export const FontFamily = ({ id, value, disabled$ }: IFontFamilyProps) => {
const viewValue = useMemo(() => {
if (value == null) return '';
let fontFamily = localeService.t(`fontFamily.${(`${value ?? ''}`).replace(/\s/g, '')}`);
// Handle font family from copy paste.
if (fontFamily.startsWith('fontFamily.') && typeof value === 'string') {
fontFamily = value.split(',')[0];
const fixedValue = (`${value ?? ''}`).replace(/\s/g, '');
const font = fonts.find((font) => {
return font.value === fixedValue;
});
if (!font) {
return fixedValue;
}
return fontFamily;
}, [value]);
return localeService.t(font.label);
}, [value, fonts]);
useMemo(() => {
setInputValue(viewValue);