diff --git a/packages/core/src/hook/useSx.test.ts b/packages/core/src/hook/useSx.test.ts index 96ed9ac..106f49b 100644 --- a/packages/core/src/hook/useSx.test.ts +++ b/packages/core/src/hook/useSx.test.ts @@ -74,6 +74,12 @@ const baseTheme: ThemedDict = { fontStyle: 'normal', fontWeight: '400', }, + body: { + fontFamily: 'Noto Sans', + fontSize: 12, + fontStyle: 'normal', + fontWeight: '400', + }, }, }; @@ -241,6 +247,23 @@ describe('style parse priority', () => { { fallback: { width: 1, marginX: 5 }, expectation: { width: 2, marginHorizontal: 4 } }, ); }); + + it('sx typography > fallback', () => { + expectResult( + baseTheme, + { t: 'title' }, + { + fallback: { typography: 'body' }, + expectation: { + fontFamily: 'Noto Sans', + fontSize: 14, + fontStyle: 'normal', + fontWeight: '400', + }, + styleType: 'TextStyle', + }, + ); + }); }); describe('radii', () => { diff --git a/packages/core/src/internal/util/mutateShortcutPropToOriginalKeys.ts b/packages/core/src/internal/util/mutateShortcutPropToOriginalKeys.ts index 35d838a..4e0ac82 100644 --- a/packages/core/src/internal/util/mutateShortcutPropToOriginalKeys.ts +++ b/packages/core/src/internal/util/mutateShortcutPropToOriginalKeys.ts @@ -6,13 +6,15 @@ export function mutateShortcutPropToOriginalKeys(sx?: TextSxProps | null) { return sx; } + const ret = { ...sx }; + for (const key of Object.keys(sx)) { if (SHORTCUT_NAME_MAP[key]) { - if (!(SHORTCUT_NAME_MAP[key] in sx)) { - sx[SHORTCUT_NAME_MAP[key]] = sx[key]; + if (!(SHORTCUT_NAME_MAP[key] in ret)) { + ret[SHORTCUT_NAME_MAP[key]] = sx[key]; } } } - return sx; + return ret; }